Gradient Null Space Projection
- GNSP is a technique that projects gradient updates into the null space of constraints, ensuring that primary tasks remain unaffected during secondary optimization.
- It is applied in robotics, continual learning, adversarial training, and prompt tuning to maintain feasibility and prevent unwanted interference between tasks.
- Various implementations—from classical projectors to learned and exact editing formulations—balance efficiency, accuracy, and robustness against subspace misestimation.
Gradient Null Space Projection (GNSP) denotes a class of update rules in which a gradient, control command, or gradient-like direction is projected into the null space of a protected operator before being applied. In the classical constrained setting, the protected operator is a constraint Jacobian or task Jacobian, so the projected update remains tangent to the feasible manifold or orthogonal to higher-priority task directions. In later work, the same construction is instantiated with decision-boundary operators, feature covariances, benign-activation subspaces, anchor activations, and layer-input spaces, yielding non-interference objectives in adversarial training, continual learning, optimization acceleration, activation steering, and model editing (Lin et al., 2016, Peng et al., 26 Jul 2025).
1. Mathematical foundation
In constrained kinematic systems, the configuration satisfies equality constraints with constraint Jacobian . Feasible infinitesimal motions lie in the tangent space of the constraint manifold, equivalently in . The classical kinematic null-space projector is
where is the Moore–Penrose pseudoinverse. This projector is idempotent, satisfies and , and maps any joint-space vector onto the constraint null space. A weighted variant is
and the dynamically consistent operational-space form is
These variants differ only in the metric used to define orthogonality and consistency (Lin et al., 2016).
GNSP applies the projector to a descent direction. For an objective subject to 0, the canonical discrete and continuous forms are
1
If 2 is feasible, then the linearized constraint change is 3. Substituting 4 gives 5, so the constraints are preserved up to first order for sufficiently small 6 and smooth 7. In operational-space language, GNSP is the gradient analogue of prioritized null-space control: a secondary descent direction is projected so that it cannot interfere with the primary task (Lin et al., 2016).
A recurring point of terminology is that some papers implement the mechanism without explicitly naming it. The essential criterion is structural rather than lexical: a projected update of the form 8, 9, or an equivalent null-space factorization is a GNSP construction when 0 spans the protected subspace.
2. Learning the projector under unknown constraints
A central difficulty in robotics is that the constraints themselves may be unknown. “Learning Null Space Projections in Operational Space Formulation” addresses the case in which neither the constraint geometry 1, nor its Jacobian, nor the underlying policy is known a priori; only demonstrations of constrained actions are observed. The paper assumes data
2
with the generative model
3
where 4 encodes constraints, 5 is a task-space policy, 6 is the null-space projector, and 7 is a shared null-space policy across demonstrations (Lin et al., 2016).
The learning pipeline has three stages. First, the null-space component is estimated directly from data. Following Towell et al. (IROS 2010), the estimate 8 is obtained by minimizing
9
with
0
This exploits the identity 1, after which the task-space residual is 2 (Lin et al., 2016).
Second, the projector is recovered by enforcing both idempotent reconstruction on the null-space component and orthogonality to the task-space component:
3
The key observation is that optimizing only 4 can overestimate rank, while optimizing only 5 can underestimate rank. The combined objective
6
is therefore essential for rank recovery. Under sufficiently rich data such that 7 spans 8 and 9 spans 0, identifiability follows (Lin et al., 2016).
Third, the constraint operator is parameterized and estimated. If the task Jacobian is known, the paper sets 1 and learns a task-space selection matrix 2 via nonlinear least squares with Levenberg–Marquardt. If 3 is unknown, each constraint row is modeled as a unit, mutually orthogonal vector 4 with angular parameterization
5
where 6 are normalized radial basis functions built from Gaussian kernels with centers from k-means. The rows are added iteratively; a new row is retained only if it does not increase the combined objective. The reported evaluations show effectiveness across problems of differing dimensionality and varying degrees of non-linearity, recovering the correct null-space projector and constraint rank without prior knowledge of the underlying policy, constraint geometry, or dimensionality (Lin et al., 2016).
3. Operational-space hierarchy and control composition
In redundant robots, GNSP is most naturally embedded in prioritized inverse kinematics and operational-space control. For a single task 7 with Jacobian 8, the right pseudoinverse solution uses
9
and the null-space projector is 0. A secondary objective 1 is then introduced through
2
so that only the component of 3 orthogonal to the primary task survives. For multiple tasks, the recursive construction uses restricted Jacobians 4 and
5
which yields strict priority: each lower-priority term is orthogonal, through successive projectors, to the subspaces spanned by higher-priority task Jacobians (Patil et al., 28 Mar 2025).
The same logic carries over from kinematic velocity control to control-affine dynamics. In the control-input setting, lower-priority controls are explicitly projected into the null space of higher-priority tasks before summation. The paper “Task Hierarchical Control via Null-Space Projection and Path Integral Approach” further combines this hierarchy with Path Integral control by reserving one lower-priority task for PI optimization while higher-priority tasks are handled by PD-like controllers. The projected dynamics are written with
6
so the PI-controlled input acts only within the null space of higher priorities (Patil et al., 28 Mar 2025).
The simulations clarify the functional role of GNSP in a hierarchy. In a single-agent unicycle example, obstacle avoidance is the highest-priority task and move-to-goal is lower priority. With perturbation 7, cost 8, terminal cost 9, 0, and 1 Monte Carlo samples, PD-only hierarchy oscillates and fails to reach the goal due to local minima, whereas PI in the null space yields 100 successful trajectories that avoid the obstacle and reach the goal. The paper notes explicitly that it does not use the term “GNSP,” but its methodology directly supports the classic GNSP strategy of injecting projected gradient-based secondary commands into a null-space hierarchy (Patil et al., 28 Mar 2025).
4. Continual learning and preservation of learned subspaces
In continual learning, the protected subspace is not a constraint manifold in joint space but a representation subspace associated with previous tasks. “GNSP: Gradient Null Space Projection for Preserving Cross-Modal Alignment in VLMs Continual Learning” applies this idea to CLIP-style models. Let 2 and let 3 span a subspace important for previous tasks. The projected gradient is
4
Rather than storing gradients, the paper builds layerwise null spaces from feature covariances: after each task, it stores normalized Gram matrices 5, accumulates them, and uses the small-singular-value subspace to form the projector 6. An adaptive threshold 7 controls the retained null-space dimension. The method is applied to the 12 FFN layers of the CLIP image encoder and is combined with Contrastive Distillation and Modality Alignment Preservation to stabilize the multimodal embedding geometry. On MTIL, the reported results are Transfer 68.9, Average 77.3, Last 86.4 for Order I and 65.7, 76.7, 87.7 for Order II; on COCO Captions retrieval, GNSP obtains 8, close to zero-shot CLIP at 9 (Peng et al., 26 Jul 2025).
The same principle becomes architecture-specific in prompt tuning for ViTs. “Visual Prompt Tuning in Null Space for Continual Learning” derives two sufficient consistency conditions for prompt updates in self-attention:
0
together with a LayerNorm-invariance constraint. The resulting projected prompt update is two-sided,
1
where 2 and 3 are null-space projectors obtained from SVDs of accumulated constraint covariances. This is a transformer-specific GNSP construction: one projector enforces affinity consistency and the other aggregation consistency. The paper reports substantial gains over sequential prompt tuning, including 10-split CIFAR-100 accuracy from 87.27 to 91.74 with forgetting from 12.33 to 3.28, and 10-split DomainNet accuracy from 73.28 to 83.54 with forgetting from 25.65 to 8.54 (Lu et al., 2024).
A closely related but deliberately distinct formulation is NESS, which enforces orthogonality in weight space rather than through per-step gradient projection. It estimates an approximate null space from the smallest singular values of layer inputs and parameterizes updates as
4
with 5 fixed and only 6 trainable. The paper explicitly contrasts this with GNSP: the constraint is baked into the parameterization rather than applied to each gradient. This positions NESS as a weight-space alternative to GNSP rather than a direct instance of it, while preserving the same geometric objective of updating along directions nearly orthogonal to previous inputs (Pham et al., 25 Feb 2026).
5. Robustness, steering, and exact model editing
Outside robotics and continual learning, GNSP has been recast as a way to preserve trusted behavior while modifying vulnerable directions. In adversarial training, “NPAT Null-Space Projected Adversarial Training Towards Zero Deterioration” defines a decision-boundary operator at the penultimate layer using the last linear map of a high-accuracy pretrained model. With 7, the null-space projector is
8
or, in the paper’s closed form when applicable,
9
Two algorithms are then defined. Null-space Projected Gradient Descent projects the last-layer gradient,
0
whereas Null-space Projected Data Augmentation projects adversarial perturbations through penultimate features before chaining them back to the input. On CIFAR-10, the paper reports for NPGD + TRADES clean error 6.54%, PGD error 28.17%, and AA error 28.37; for NPDA + TRADES it reports 6.38%, 43.27%, and 43.27, respectively (Hu et al., 2024).
In inference-time safety steering for vision-LLMs, “Principled Steering via Null-space Projection for Jailbreak Defense in Vision-LLMs” constructs a benign subspace from hidden activations and projects steering updates into its null space. The deployed activation rule is
1
so benign inputs with 2 receive near-zero perturbation, whereas harmful inputs with non-benign components are dynamically steered. The paper also gives a Jacobian-based GNSP view:
3
which guarantees first-order invariance of benign outputs under the chosen benign objective. Empirically, the paper reports average ASR reduction over 15 percent on MiniGPT-4 while maintaining comparable performance to the original model on general benchmarks (Zhu et al., 23 Mar 2026).
A stronger exactness result appears in model editing. “X-Edit: Exact, Explicit, and Explainable Null-Space Editing for Medical Vision Transformers” localizes influential MLP layers by causal tracing, builds an anchor key matrix 4, and computes a projector
5
from the small-eigenvalue subspace of 6. The edit is constrained to the form 7, which yields exact anchor invariance because 8 implies
9
The closed-form solution is
0
where 1. Unlike iterative fine-tuning, this is a one-shot null-space constrained solve. Across six medical imaging benchmarks, the reported Fix Ratios are 100% on BloodMNIST, OrganAMNIST, RetinaMNIST, LiFS-sub1, and LiFS-sub2, and 98.92% on DermaMNIST, with substantially smaller forgetting than fine-tuning and EWC (Liu et al., 24 May 2026).
6. Optimization acceleration, numerical practice, and recurrent limitations
GNSP can also be used without an external constraint task, by preserving the current loss while optimizing a secondary geometric objective. “Teleportation With Null Space Gradient Projection for Optimization Acceleration” defines
2
and updates each layer by projecting the teleportation gradient into the input null space:
3
For MLPs, CNNs, and self-attention projections, the layer preactivation is linear in 4 and the layer input 5, so enforcing 6 by null-space projection preserves the network outputs on the teleportation batch. The paper constructs the relevant subspace with an SVD of a representation matrix 7 and shows exact batchwise loss invariance when 8, with controlled violation when 9 (Wu et al., 17 Feb 2025).
Across domains, several implementation issues recur. Pseudoinverse computations are unavoidable in many formulations: for 00, 01 via SVD costs 02 when 03, and dynamically consistent projectors require inversion of matrices such as 04. The robotics literature recommends damped least squares near singularities,
05
together with Cholesky factorizations for SPD matrices, Gram–Schmidt or constrained optimization to enforce orthonormality of learned constraint rows, and spectrum monitoring of 06 to validate recovered rank (Lin et al., 2016).
The principal failure mode is subspace misestimation. In learned-projector settings, if 07 and 08 do not span their respective subspaces, the projector is not identifiable; optimizing only idempotency or only orthogonality leads to rank misestimation. In continual learning, as accumulated feature covariances become nearly full rank, the usable null space can shrink and over-constrain plasticity; this is the basis-drift problem emphasized in CLIP-style GNSP. In activation steering, benign invariance is first-order unless the update is exactly annihilated by the benign projector, so larger steering magnitudes can introduce second-order drift. In hierarchical control, null-space projection does not resolve infeasibility: if tasks conflict or the null space collapses, lower-priority commands are sacrificed rather than reconciled (Lin et al., 2016, Peng et al., 26 Jul 2025, Zhu et al., 23 Mar 2026).
A recurrent misconception is that all null-space methods are interchangeable. The literature instead separates at least three regimes. Classical GNSP projects instantaneous gradients or commands into a null space. Learning-based robotics methods infer the projector itself from demonstrations. Weight-space null-space methods such as NESS embed the constraint into the parameterization and therefore are related but not identical. Exact editing methods such as X-Edit replace iterative projection with a closed-form null-space constrained solve. What unifies these formulations is the same geometric statement: protected behavior is represented by a subspace, and permissible change is restricted to its null space.