CCFM: Collision-Constrained Flow Matching for Safety-Critical Scenario Generation¶
Conference: ECCV 2026
Paper: ECCV Official Page
PDF: Full Paper
Code: https://github.com/KELISBU/CCFM
Area: Autonomous Driving
Keywords: Safety-Critical Scenario Generation, Flow Matching, Collision Hard Constraints, Manifold Projection, Closed-Loop Simulation
TL;DR¶
CCFM reformulates safety-critical driving scenario generation as flow matching sampling with hard collision constraints: it first dynamically selects feasible adversarial vehicles and collision types, and then progressively projects action sequences using contact point, relative heading, and severity constraints. It improves the collision rate to 46.4%/83.1% on nuScenes/nuPlan in an 80-frame closed-loop simulation, while achieving a collision type matching rate of 84.3%/85.6%.
Background & Motivation¶
Autonomous driving planners need to undergo stress testing with rare accidents in closed-loop environments. However, real-world accidents are low-frequency and dangerous, making them impossible to cover through natural data collection. Optimization or reinforcement learning methods like STRIVE and KING can push traffic participants into dangerous states, but they tend to produce overly aggressive actions that deviate from the human driving distribution. Diffusion generators like CCDiff and SAFE-SIM learn more realistic traffic priors, but they typically use collision costs as soft guidance, which only increases the probability of being "more likely to collide" and cannot guarantee that collisions occur at designated contact regions with specified relative headings and impact intensities.
Precise control is also limited by scenario conditions. The same target collision type is not applicable to any arbitrary vehicle: whether nearby vehicles can reach the ego vehicle, whether the current relative pose matches the geometry of a rear-end or side collision, and whether the lane topology is legal all determine if the constraints are solvable. Handing all vehicles and four collision modes to a sampler for joint search is computationally expensive and frequently pursues physically unreasonable goals.
Instead of treating collision as a cost term that can be ignored by generative priors, this paper formulates the target accident as a feasible set that the sampling endpoint must satisfy while preserving the realistic traffic flow distribution. Core Idea: A heuristic collision selector first chooses the most feasible "adversarial vehicle-collision type" combination based on reachability, geometry, and road legality. Then, contact points, relative headings, and severity are formulated as hard residuals, and a Gauss-Newton projection is used at each step of the flow matching ODE to pull the action sequence back to the collision constraint manifold.
Method¶
Overall Architecture¶
CCFM operates in a rolling-horizon closed-loop simulation. During each replanning step, the ego vehicle generates its future trajectory using the planner under test, while normal traffic participants sample actions from a conditional flow matching prior; the system applies collision constraints only to a single selected adversarial vehicle. The sampler generates an action sequence for the future 32 frames, which is rolled out via single-track vehicle dynamics to obtain trajectories, but only the first action is executed before the scenario is updated and replanned.
The three contributions of the method act sequentially: the heuristic collision selector first determines the adversarial vehicle and one of the four types (rear-end, side, cut-in, front-end); the categorized hard collision constraints convert the target accident into three endpoint residuals; the collision-constrained flow matching performs projection at each ODE integration step and maps the corrected endpoint back to the current flow time along the optimal transport path. Normal reactive vehicles maintain unconstrained sampling, so the hard intervention is concentrated on the vehicle generating the accident.
flowchart TD
A["Current Traffic State<br/>and Ego Plan"] --> B["Heuristic Collision Selector"]
B -->|Vehicle + Type| C["Categorized Collision Hard Constraints"]
C -->|Feasible Set| D["Collision-Constrained Flow Matching"]
D --> E["Adversarial Action Sequence<br/>and Reactive Vehicle Trajectories"]
E --> F["Execute First Action<br/>& Closed-Loop Replanning"]
Key Designs¶
1. Heuristic Collision Selector: Screening Out the Physically Most Feasible Accident Targets First
The selector enumerates non-ego vehicles \(i\) and four collision types \(m\) at each step, but instead of running expensive constraint sampling, it pre-evaluates combination feasibility using three interpretable scores. The reachability score measures the spatial proximity between the vehicle and the ego vehicle; the geometric score compares the current relative pose with the typical pose of that collision category; the road legality score compares the lane topological relationship of both parties with the typical topology of that collision type. The weighted sum of these three yields
where the sum of weights is 1, and only the highest-scoring combination \((i^*,m^*)\) enters the subsequent projection. This decoupling is crucial: it prevents continuous optimization from bearing discrete mode selection, and avoids generating unrealistic maneuvers for targets (such as "head-on collision") that do not match the current lane relationships. The selector also acts as a replaceable plugin, allowing users to override automatic selection to test a specific vehicle or collision type.
2. Categorized Collision Hard Constraints: Defining Accidents via Three Residuals Jointly, Rather Than Solely Requiring Trajectory Intersection
A collision type is not defined solely by "two bounding boxes intersecting". CCFM calculates three quantitiesโcontact point, relative heading, and severityโat the predicted collision time \(t+T_{\mathrm{col}}\), and sets target values according to rear-end, side, cut-in, and front-end collisions. The residual vector is expressed as
The contact point residual is responsible for positioning the collision on the target vehicle body region; the relative heading residual distinguishes between same-direction rear-end, lateral side, and head-on conflicts; the severity residual constrains the relative velocity upon collision. Thus, "accident type" becomes a verifiable geometric and kinematic condition rather than a post-generation semantic label. The target collision time is updated at each round of closed-loop replanning based on the current motion states of the ego and adversarial vehicles, and the Jacobian is automatically computed via differentiable forward dynamics rollout.
3. Collision-Constrained Flow Matching: Stepwise Hard Projection While Preventing Early Samples from Being Bluntly Pulled Away from the Data Manifold
The base model encodes raster maps and historical trajectories using a ResNet, and predicts conditional flow velocities using a U-Net with 1D convolutional blocks. The training context consists of 10 history frames to output 32 future action frames. Inference starts from a Gaussian noise action sequence and integrates the flow matching ODE with \(K\) Euler steps. Each step first obtains an unconstrained candidate based on the velocity field, and then solves for the action sequence closest to the candidate that satisfies \(\mathbf{h}_t=0\) using damped Gauss-Newton; automatic differentiation propagates the collision residuals back through vehicle dynamics to the entire profile of acceleration and yaw rate.
If the projection result directly replaces the sample when the flow time is small, the state (still close to noise) would undergo a massive jump. CCFM thus adopts optimal transport (OT) reverse updating to blend the projected endpoint with the initial noise based on the current flow time:
When \(\lambda\) is close to 0, the iteration remains close to the original generation path; when \(\lambda=1\), the result is exactly equal to the hard-projected endpoint. This allows the method to integrate real-world driving prior with terminal collision constraints during inference without retraining the flow model.
A Complete Example¶
Suppose there are multiple non-ego vehicles in the current scene. HCS first calculates scores for four accident modes for each vehicle. A vehicle located in the adjacent lane and within reachable distance might win due to a match in both cut-in geometry and topology. The system then designates this vehicle as the adversarial vehicle, requiring it to hit the side of the ego vehicle at the predicted collision time, establishing the relative heading required for a cut-in while reaching the target relative speed.
Sampling begins with a sequence of Gaussian noise actions. Each Euler step first moves along the velocity field learned from real traffic data, and then checks the future contact state using dynamics rollouts. Gauss-Newton applies minimal corrections to the 32 frames of acceleration and yaw rate based on the three residuals, and the OT update progressively increases the correction intensity from early to late stages. The final action sequence satisfies the constraints at the endpoint, but only the first frame of action is executed in the closed-loop environment. If the ego planner takes evasive action, the next round will re-evaluate the target and collision time based on the new state. Thus, the hard constraints target a dynamic accident configuration rather than forcing the replay of a fixed trajectory regardless of interaction.
Loss & Training¶
The generative prior of this paper follows conditional flow matching training, and the key innovation lies in test-time constraint sampling without retraining. The closed-loop simulation replans at 2 Hz, predicting 32 future action frames using a 10-frame history condition. The standard planning horizon is 8 seconds, with an additional 20-second rollout evaluated. The ego vehicle is controlled by the lane-graph rule-based planner from STRIVE, PDM, and IDM, respectively, while non-adversarial vehicles continue to be controlled by the unconstrained generative prior.
Key Experimental Results¶
Main Results¶
The following table shows the closed-loop comparison under the same lane-graph ego planner. CR is the scene-level collision rate involving the ego and the adversarial vehicle, MS is the collision relative speed, and TM is the target collision type matching rate. Since the baselines do not provide type-level control, their TM is denoted as "โ".
| Dataset / Horizon | Method | CR (%) โ | MS (m/s) โ | TM (%) โ | OR (%) โ | RM โ | Time (s) โ |
|---|---|---|---|---|---|---|---|
| nuScenes / 80 frames | CCDiff | 4.0 | 0.3 | โ | 4.4 | 0.49 | 180.5 |
| nuScenes / 80 frames | STRIVE | 20.8 | 1.9 | โ | 5.8 | 0.83 | 466.3 |
| nuScenes / 80 frames | SAFE-SIM | 25.8 | 0.8 | โ | 5.0 | 0.63 | 128.9 |
| nuScenes / 80 frames | CCFM | 46.4 | 2.8 | 84.3 | 5.4 | 0.78 | 123.0 |
| nuPlan / 80 frames | SAFE-SIM | 42.1 | 2.4 | โ | 3.6 | 0.33 | 271.4 |
| nuPlan / 80 frames | CCFM | 83.1 | 5.2 | 85.6 | 1.7 | 0.33 | 356.3 |
| nuScenes / 200 frames | CCFM | 59.9 | 4.0 | 85.4 | 11.4 | 0.71 | 316.3 |
| nuPlan / 200 frames | CCFM | 95.2 | 6.1 | 84.7 | 1.9 | 0.30 | 970.5 |
At 80 frames, CCFM improves the collision rate by 20.6 percentage points on nuScenes and by 41.0 percentage points on nuPlan compared to the strongest collision rate baseline SAFE-SIM. Extending the horizon to 200 frames further increases the collision rate, but the OR for nuScenes increases from 5.4% to 11.4%, and the runtime for nuPlan also increases from 356.3 seconds to 970.5 seconds, showing that the danger introduced by a longer horizon is not without realism and computational costs.
Ablation Study¶
| Configuration | CR (%) โ | TM (%) โ | MS (m/s) โ | EN โ | DS โ | CWS โ |
|---|---|---|---|---|---|---|
| Contact Point Constraint Only | 51.6 | 82.1 | 2.3 | 0.85 | 0.90 | 0.92 |
| + Relative Heading Constraint | 48.4 | 83.8 | 2.6 | 0.86 | 0.92 | 0.93 |
| + Severity Constraint (Full Constraints) | 46.4 | 84.3 | 2.8 | 0.89 | 0.96 | 0.96 |
| Unconstrained FM | 8.2 | โ | 0.7 | 0.63 | 0.48 | 0.56 |
| FM + Soft Collision Guidance \(J_{\mathrm{col}}\) | 10.2 | โ | 0.8 | 0.70 | 0.43 | 0.43 |
| FM + GN Hard Projection | 46.4 | โ | 2.8 | 0.89 | 0.97 | 0.89 |
Key Findings¶
- The contact point constraint alone achieves the highest collision rate, but the full constraints improve TM from 82.1% to 84.3%, and MS from 2.3 m/s to 2.8 m/s; CR drops to 46.4%, reflecting that more specific constraints lead to a smaller feasible solution space.
- Soft guidance only increases the CR of unconstrained FM from 8.2% to 10.2%, whereas GN hard projection reaches 46.4%, providing the most direct evidence for the paper's claim that "hard constraints outperform probabilistic preferences".
- The CWS of HCS is 0.89, which is higher than fixing rear-end (0.68), front-end (0.67), side (0.67), and cut-in (0.77). Instead of always performing best on a single metric, it achieves a more stable combination of feasibility, category control, danger, and realism.
- When switching between IDM, PDM, and lane-graph ego planners, the CR is 51.6%, 36.1%, and 46.4%, respectively, and the TM is 82.7%, 81.2%, and 84.3%. The explicit collision avoidance of PDM results in the lowest collision rate, which also demonstrates that the generator is indeed affected by the closed-loop response of the planner under test.
Highlights & Insights¶
- The paper shifts "generating hazardous scenarios" from maximizing risk cost to solving structured feasible sets. This shift allows collision types to be interpreted and verified by contact region, heading, and speed, rather than judging generation success solely by whether a collision ultimately occurred.
- HCS performs discrete object/type selection prior to continuous action optimization, which is a highly practical hierarchical design. A similar approach can be transferred to robot contact planning: first screen reachable contact modes, then execute differentiable constraint projection for the chosen mode.
- OT reverse updating resolves the misalignment of flow times between the hard projection and the generated trajectory. It forces early iterations to respect the transport path from noise to data while strictly satisfying constraints at the end, serving as a key connector to port physical constraint sampling from PDE scenarios to interactive traffic scenarios.
- The paper does not merely report collision rates; it also decomposes "dangerous yet realistic" using type matching, contact region entropy, relative velocity/heading variance, motion distribution distance, and out-of-road rate. This multi-axial evaluation is more suitable for safety testing generators than a single accident rate.
Limitations & Future Work¶
- Hard constraints do not mean collisions are guaranteed to occur in every closed-loop round. Road topology, current traffic states, projection feasibility, and ego evasive actions can all alter the final outcome. The 80-frame nuScenes CR of 46.4% is not contradictory to the terminal action sequence satisfying the constraints, because the closed-loop environment only executes the first action before replanning.
- The authors explicitly note that the current evaluation does not distinguish between "collisions that the planner could have avoided" and "collisions that were physically unavoidable". Subsequent work should incorporate avoidability or responsibility assessment; otherwise, a high collision rate might mix valid exposure of planner flaws with simply creating unsolvable situations.
- A longer horizon increases CR but is accompanied by escalating out-of-road rates and runtimes. At 200 frames, nuScenes OR reaches 11.4% and the single complete closed-loop runtime for nuPlan is 970.5 seconds. For large-scale regression testing, faster projection solvers and explicit road feasibility constraints are required.
- Behavioral prior is trained on nuScenes and evaluated on nuScenes validation and nuPlan mini validation; evidence of generalization across cities, weather, sensor conditions, and larger nuPlan splits remains limited. The paper has also not yet shown whether generated accidents can improve real-world systems via sim-to-real transfer.
- Constraints only cover rear-end, side, cut-in, and front-end collisions, and only designate one adversarial vehicle at a time. Multi-vehicle pile-ups, pedestrian/cyclist interactions, non-contact cut-offs, and other safety events require more rich participant models and temporal logic constraints.
Related Work & Insights¶
- vs SAFE-SIM / CCDiff: These methods increase risk probability via cost guidance during diffusion sampling, whereas CCFM formulates accident conditions as endpoint-satisfying residuals in flow matching. The former is more flexible with lower implementation costs, while the latter is stronger in type control and collision rates, though it must bear the costs of Jacobians, iterative projection, and feasibility assessment.
- vs STRIVE / KING: Optimization-based adversarial scenario generation directly drives trajectories toward danger, which easily deviates from driving data distributions. CCFM preserves the learned flow prior and applies minimal constraint correction only to the intermediate action sequence of a single adversarial vehicle. However, the ADV.ADE/FDE in experiments is still higher than SAFE-SIM, showing that "having a prior" does not automatically equate to closer-to-real trajectories.
- vs PCFM / HardFlow: They demonstrate that flow matching can satisfy physical hard constraints like PDEs during inference. CCFM advances this idea to closed-loop traffic interaction: constraints are mediated by vehicle dynamics, defined relative to the continuously changing ego trajectory, and target collision times are updated at every round. This suggests that hard-constraint generation can be further extended from static physical systems to feedback control systems.
- For downstream planner training, a more valuable direction is not to infinitely increase the accident rate, but to sample hierarchically by collision type, avoidability, and severity, and then compare the changes in failure clusters before and after planner fixes. CCFM already provides type and severity knobs, but still lacks closed-loop evidence from stress testing to targeted training.
Rating¶
- Novelty: โญโญโญโญโ Introducing collision type hard constraints and stepwise flow matching projection into closed-loop traffic generation, with a clear combination targeting the weaknesses of soft guidance.
- Experimental Thoroughness: โญโญโญโญโ Covering two datasets, two horizons, three planners, and three groups of key ablations, but nuPlan only uses mini validation, and it lacks sim-to-real and avoidability analysis.
- Writing Quality: โญโญโญโญโ The three components, constraint definitions, and algorithmic workflows correspond clearly, and main trade-offs are supported by data; some specific forms of constraints are in the supplementary material, and main text reproduction details are slightly brief.
- Value: โญโญโญโญโ Provides a more reliable technical route for controllable accident stress testing than soft guidance, suitable for identifying planner weaknesses, but high computational overhead and limited event types still restrict direct deployment.