Diffusion transformers often need to condition their generation on multiple signals at once -- for example, a diffusion timestep, a class label, and a text embedding. These signals may have different dimensions and must be combined into a unified conditioning vector that modulates the model's hidden features.
Implement multi_signal_conditioning that takes hidden features along with an arbitrary number of conditioning signals and their associated projection parameters, combines the signals, derives per-feature scale and shift values, and applies residual affine modulation to produce the output.
Arguments:
features: (N, D) array of hidden featuressignals: list of K arrays, the k-th of shape (N, D_k)proj_weights: list of K weight matrices, the k-th of shape (D_k, D_emb)proj_biases: list of K bias vectors, each of shape (D_emb,)mod_weight: (D_emb, 2*D) weight for modulation parameter generationmod_bias: (2*D,) bias for modulation parameter generationThe conditioning pipeline works as follows:
D_emb using its weight and bias (affine transformation).mod_weight and mod_bias to get 2*D values per sample. Split these into gamma (first D values) and beta (last D values).Return the (N, D) modulated features as a numpy array.