Introduction
A base-resolution sequence-to-function model such as BPNet [1] reads about a kilobase of DNA and predicts, for each assay track, two things: a profile , a distribution over the positions (and strands) of the output window, and a log total count . The observed data for one track of one example are integer read counts with total . The question of this task is how to train the two heads so that both the profile shape and the total signal improve on held-out chromosomes, with the architecture, optimiser, sampling and augmentation fixed.
The standard objective is a multinomial negative log-likelihood of the reads under , on peaks, plus a weighted squared error on [1, 2]. Two properties of that sum make it a poor balance of the two tasks.
Profiles are weighted by their read mass, not by how much they say. The multinomial likelihood of a peak grows with , so the deepest peaks dominate the profile gradient. But a deep peak's profile is not proportionally more informative: once the reads resolve the latent shape, more reads add little, while shallow peaks, which are most of the data, are almost all shot noise. Per-base Poisson and cross-entropy variants [3, 4, 5] and shape-only losses [6, 7] change the likelihood but leave this weighting question largely open.
The two tasks have no common unit. A profile loss in nats and a count loss in squared log-units are added with a fixed weight, and how hard each task pulls on the shared trunk then depends on the assay. Multi-task learning offers gradient-level balancing [8, 9, 10, 11, 12], but these methods balance the observed minibatch gradients, which on sparse genomic data are mostly sampling noise. Balancing noise is not balancing tasks.
Method
Our method, SHIFT (split-half filtered, information-scaled training), addresses each property in turn: it measures how reliable each profile is from the reads themselves, puts both tasks in statistical units, and then weighs the tasks by the reproducible part of their gradients only.
How much of a profile is signal
For a track with latent profile and reads drawn from it, the number of distinct read pairs that fall on the same base gives an unbiased estimate of the collision probability without any shot noise:
If follows a symmetric Dirichlet prior with total concentration , then , and solving for gives the concentration that matches the measured collisions,
has a direct reading: a peak with reads has posterior-mean profile , with , uniform, and reliability . We estimate once per track on a sample of training peaks, together with the spread of , floored at 0.35, which standardises the count task.
for start in range(0, len(rows), batch_rows):
sample = counts[rows[start:start + batch_rows], :, kit.J:kit.J + kit.OUT]
sample = sample.reshape(len(sample), kit.T, width).astype(np.float64)
total = sample.sum(-1)
# Distinct read pairs estimate squared latent probabilities without shot noise.
pairs = (sample * (sample - 1)).sum(-1)
collision_sum += (pairs / np.maximum(total * (total - 1), 1)).sum(0)
observations += (total > 1).sum(0)
log_totals.append(np.log1p(total))
collision = np.where(observations > 0, collision_sum / observations.clip(1), 1 / width)
threshold = (1 - collision) / np.maximum(collision - 1 / width, 1 / (8 * width))
depth_cpu = torch.as_tensor(threshold.clip(1, 8 * width), dtype=torch.float32)
depth = depth_cpu.to(kit.device)
deviation = np.concatenate(log_totals).std(0) if log_totals else np.ones(kit.T)
scale = torch.as_tensor(deviation.clip(0.35), dtype=torch.float32, device=kit.device)A common unit for both tasks
The information a profile carries is its divergence from a uniform read. Under the Dirichlet posterior its expectation has a closed form,
which integrates the uncertainty about bases that received no reads. We average it over training peaks with weights , obtaining per track, and measure the profile loss in units of . For a profile near uniform, is the displacement in the local Fisher metric, the same kind of unit as a standardised count residual, so the two tasks become comparable before any gradient is balanced.
# The information of a profile is its KL divergence from a uniform read.
# A symmetric Dirichlet prior with concentration K has the measured collision
# probability. The posterior expected KL integrates uncertainty in unseen bases.
concentration = depth_cpu.double()
prior = concentration / width
prior_info = math.log(width) - torch.digamma(1 + concentration) + torch.digamma(1 + prior)
information = torch.zeros_like(prior)
precision = torch.zeros_like(prior)
tables = [torch.empty(0, dtype=torch.float64) for _ in range(kit.T)]
rows = np.linspace(0, len(counts) - 1, min(len(counts), 4096), dtype=int)
for start in range(0, len(rows), batch_rows):
sample = counts[rows[start:start + batch_rows], :, kit.J:kit.J + kit.OUT]
sample = sample.reshape(len(sample), kit.T, width)
total = torch.from_numpy(sample.sum(-1, dtype=np.float64))
posterior = total + concentration
weight = total / posterior
expected = math.log(width) - torch.digamma(1 + posterior)
for track in range(kit.T):
values = torch.as_tensor(sample[:, track].astype(np.int64))
size = int(values.max()) + 1
if size > len(tables[track]):
cell = torch.arange(size, dtype=torch.float64) + prior[track]
tables[track] = cell * torch.digamma(1 + cell)
expected[:, track] += tables[track][values].sum(-1) / posterior[:, track]
information += (weight * expected).sum(0)
precision += weight.sum(0)
information = torch.where(precision > 0, information / precision.clamp_min(1e-12), prior_info)
profile_scale = (2 * information.clamp_min(0.05)).sqrt().float().to(kit.device)The two loss terms
For each example and track, the profile term is the cross-entropy of the observed reads against the prediction, relative to a uniform prediction,
weighted by on peaks and on non-peak regions, so that a profile enters in proportion to how much of it is signal rather than how many reads it has. The count term uses the standardised residual on the peaks of the batch. We split it into the batch contrast and the batch offset :
The contrast is what both count correlations reward; the offset is still calibrated, but through a pseudo-Huber term whose weight falls as , the precision with which one batch can determine a mean. The profile term is , and both are averaged over tracks.
def reduce_terms(reliability, divergence, residual, peak):
profile = (reliability * divergence).sum(0) / reliability.sum(0).clamp_min(1)
n_peaks = peak.sum().clamp_min(1)
offset = (residual * peak).sum(0) / n_peaks
contrast = ((residual - offset).square() * peak).sum(0) / n_peaks
anchor = ((1 + offset.square()).sqrt() - 1) / (2 * n_peaks + 1)
return (profile / profile_scale).mean(), (0.5 * contrast + anchor).mean()
step = 0
probes = 0
moments = None
weights = np.ones(2)
def loss(logits, logcounts, y, labels, progress):
observed = kit.track_view(y)
total = observed.sum(-1)
peak = labels.to(logcounts.dtype)[:, None]
reliability = total / (total + depth) * (peak + 0.35 * (1 - peak))
logp = kit.track_view(logits).log_softmax(-1)
divergence = -(observed * (logp + math.log(width))).sum(-1) / total.clamp_min(1)
residual = (logcounts - total.log1p()) / scale
rows = (reliability, divergence, residual, peak)
profile, count = reduce_terms(*rows)
joint = profile + count
# The scalar is a stationary validation risk. Only its training differential
# is preconditioned; the trainer's combine callback advances the probe count.
if step % 24 or len(logits) < 8:
weighted = float(weights[0]) * profile + float(weights[1]) * count
return {"joint": weighted + (joint - weighted).detach()}
first = reduce_terms(*(x[::2] for x in rows))
second = reduce_terms(*(x[1::2] for x in rows))
half_sum = 0.5 * (first[0] + first[1] + second[0] + second[1])
correction = (joint - half_sum).detach()
return {"profile_a": 0.5 * first[0] + correction, "count_a": 0.5 * first[1],
"profile_b": 0.5 * second[0], "count_b": 0.5 * second[1]}Weighting the tasks by their reproducible gradient
The trainer exposes the Gram matrix of the per-term gradients on the shared trunk. Every 24th step (for batches of at least 8) our loss returns four terms, profile and count on the even and on the odd half of the batch. Because the halves are independent, the cross-half inner products estimate the product of the population gradients, free of minibatch noise:
with the Gram matrix of the full-batch task gradients. Both are smoothed with an exponential average at rate . We normalise by the gradient norms, , and diagonalise : its eigenvalues are the signal fractions of the task directions, clipped to and shrunk toward 1 by a ridge that is large while few probes have been seen. From the reconstructed signal we take each task's signal strength and set the target combination : the count task may be scaled down to the profile's signal strength, never up. The minimum-MSE linear estimate of that target from the observed gradients has weights
floored at . Only the ratio , clipped to , is kept, and the weights are rescaled to sum to 2.
g = gram.numpy()
# A cross-half inner product estimates the product of population means.
signal = (g[:2, 2:] + g[2:, :2]) * 0.5
total = (g[:2, :2] + g[2:, 2:] + 2 * signal) * 0.25
measured = np.stack((total, signal))
probes += 1
rate = max(1 / 12, 1 / probes)
moments = measured if moments is None else (1 - rate) * moments + rate * measured
total, signal = moments
# Relative task strength is undefined if a task has zero shared gradient.
# A single observable task can use its ordinary gradient in that case.
if np.any(total.diagonal() <= 0):
weights = np.ones(2)
return np.tile(weights, 2)
norm = np.sqrt(total.diagonal().clip(1e-15))
units = np.outer(norm, norm)
metric = total / units + 0.001 * np.eye(2)
eigen, axes = np.linalg.eigh(metric)
roots = np.sqrt(eigen.clip(0.001))
root = (axes * roots) @ axes.T
inverse = (axes / roots) @ axes.T
fractions, axes = np.linalg.eigh(inverse @ (signal / units) @ inverse)
# A signal fraction is bounded by the total observed power. Shrink uncertain
# estimates toward the unfiltered gradient while there are few probes.
effective = min(probes, 2 / rate - 1)
ridge = 1 / (1 + math.sqrt(effective))
fractions = (1 - ridge) * fractions.clip(0, 1) + ridge
signal = root @ ((axes * fractions) @ axes.T) @ root
strength = norm * np.sqrt(signal.diagonal().clip(ridge * 0.01))
target = np.array([1., min(1., strength[0] / strength[1])])
# For target population weights a, the minimum-MSE linear estimate has
# weights T^{-1} S a, with T the observed and S the signal Gram matrix.
filtered = np.linalg.solve(metric, signal @ (norm * target)) / norm
filtered = np.maximum(filtered, ridge * target)
ratio = np.clip(filtered[1] / max(filtered[0], 1e-10), 0.001, 1.)
weights = 2 * np.array([1., ratio]) / (1 + ratio)
return np.tile(weights, 2)Between probes the weights are held fixed and applied with a straight-through construction: the loss value is the unweighted sum of the two terms, a stationary risk that the validation loss reports, and only its gradient is reweighted. A normal step therefore costs one backward pass.
Selection on what is reported
The checkpoint is chosen on validation peaks by a criterion assembled from the four reported quantities' ingredients. The count part is the average of the Pearson and Spearman correlations of predicted and observed log totals. The profile part adds a per-peak profile correlation, normalised by the summed of the peaks, and the reliability-weighted log-likelihood gain over a uniform profile, divided by , half the log of what a profile at the prior's concentration can resolve:
def select(logits, logcounts, y, labels):
keep = labels.bool()
if not bool(keep.any()):
return logcounts.sum() * 0
statistics = torch.zeros((4, kit.T), dtype=torch.float64)
totals = []
for start in range(0, len(keep), 96):
active = keep[start:start + 96]
if not bool(active.any()):
continue
obs = kit.track_view(y[start:start + 96][active])
n = obs.sum(-1)
totals.append(n.log1p())
q = obs / n.unsqueeze(-1).clamp_min(1)
logp = kit.track_view(logits[start:start + 96][active]).log_softmax(-1)
reliability = n / (n + depth_cpu)
statistics[0] += ((n > 0) * correlation(q, logp.exp(), -1)).sum(0)
statistics[1] += reliability.sqrt().sum(0)
statistics[2] += (reliability * (q * (logp + math.log(width))).sum(-1)).sum(0)
statistics[3] += reliability.sum(0)
target = torch.cat(totals)
prediction = logcounts[keep]
count = 0.5 * (correlation(prediction, target, 0) +
correlation(ranks(prediction), ranks(target), 0))
profile = statistics[0] / statistics[1].clamp_min(1)
concentration = (1 + depth_cpu / width) / (1 + depth_cpu)
spread = (0.5 * (width * concentration).clamp_min(1.01).log()).clamp_min(0.15)
gain = statistics[2] / statistics[3].clamp_min(1) / spread
return -(count + 0.5 * (profile + gain)).mean()We also set the allowed trainer hyperparameters to a learning rate of 0.002 with a cosine schedule, 5% warm-up, at most 40 epochs and a patience of 12. SHIFT adds no trainable parameters, and its configuration has no per-setting constants: , and are estimated from each setting's training peaks.
Results
| Method | ① | ② | ③ | ④ | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Count Pearson r ↑ | Count Spearman ρ ↑ | Profile JS distance ↓ | Profile Pearson r ↑ | Count Pearson r ↑ | Count Spearman ρ ↑ | Profile JS distance ↓ | Profile Pearson r ↑ | Count Pearson r ↑ | Count Spearman ρ ↑ | Profile JS distance ↓ | Profile Pearson r ↑ | Count Pearson r ↑ | Count Spearman ρ ↑ | Profile JS distance ↓ | Profile Pearson r ↑ | |
| GPT-6.2 Astra | 0.703 | 0.607 | 0.558 | 0.505 | 0.707 | 0.615 | 0.344 | 0.843 | 0.595 | 0.612 | 0.695 | 0.248 | 0.730 | 0.736 | 0.582 | 0.512 |
| BPNet objective | 0.667 | 0.577 | 0.573 | 0.438 | 0.664 | 0.563 | 0.373 | 0.788 | 0.535 | 0.539 | 0.694 | 0.246 | 0.706 | 0.721 | 0.601 | 0.462 |
| ChromBPNet | 0.665 | 0.573 | 0.558 | 0.487 | 0.661 | 0.569 | 0.347 | 0.834 | 0.513 | 0.515 | 0.697 | 0.212 | 0.707 | 0.706 | 0.601 | 0.450 |
| bpAI-TAC | 0.683 | 0.564 | 0.575 | 0.436 | 0.696 | 0.587 | 0.359 | 0.816 | 0.509 | 0.513 | 0.697 | 0.230 | 0.718 | 0.724 | 0.594 | 0.477 |
| bpAI-TAC, CE + log-count MSE | 0.678 | 0.567 | 0.576 | 0.432 | 0.702 | 0.597 | 0.361 | 0.809 | 0.546 | 0.559 | 0.698 | 0.231 | 0.725 | 0.729 | 0.596 | 0.474 |
| Borzoi | 0.682 | 0.577 | 0.560 | 0.496 | 0.687 | 0.577 | 0.350 | 0.836 | 0.472 | 0.479 | 0.696 | 0.239 | 0.703 | 0.705 | 0.588 | 0.488 |
| AlphaGenome | 0.675 | 0.570 | 0.558 | 0.501 | 0.689 | 0.590 | 0.348 | 0.837 | 0.485 | 0.491 | 0.695 | 0.239 | 0.705 | 0.707 | 0.587 | 0.491 |
| Puffin, as published | 0.689 | 0.587 | 0.555 | 0.500 | 0.712 | 0.615 | 0.339 | 0.836 | 0.561 | 0.578 | 0.693 | 0.254 | 0.694 | 0.696 | 0.580 | 0.539 |
| Puffin-D | 0.667 | 0.566 | 0.571 | 0.454 | 0.679 | 0.567 | 0.360 | 0.808 | 0.517 | 0.526 | 0.697 | 0.237 | 0.726 | 0.729 | 0.596 | 0.509 |
| CLIPNET | 0.638 | 0.545 | 0.550 | 0.517 | 0.643 | 0.539 | 0.350 | 0.841 | 0.471 | 0.492 | 0.727 | 0.140 | 0.596 | 0.595 | 0.692 | 0.226 |
| Per-base MSE | 0.661 | 0.523 | 0.591 | 0.404 | 0.688 | 0.565 | 0.379 | 0.801 | 0.459 | 0.466 | 0.732 | 0.116 | 0.614 | 0.622 | 0.748 | 0.124 |
| Puffin | 0.707 | 0.607 | 0.552 | 0.507 | 0.711 | 0.613 | 0.337 | 0.839 | 0.574 | 0.586 | 0.693 | 0.255 | 0.697 | 0.697 | 0.576 | 0.541 |
- ① K562 DNase-seq · held-out chromosomes
- ② K562 ATAC-seq · held-out chromosomes
- ③ mESC ChIP-nexus · four TFs · held-out chromosomes
- ④ K562 PRO-cap · ProCapNet regions · held-out chromosomes
On the count metrics SHIFT improves on the BPNet objective on every setting and is the strongest entry on ChIP-nexus and PRO-cap. On ChIP-nexus its count Pearson r is 0.595 and its count Spearman ρ 0.612, against 0.574 and 0.586 for the strongest baseline, Puffin + cosine. On PRO-cap the corresponding values are 0.730 and 0.736, against 0.726 for Puffin-D [6]. On DNase and ATAC SHIFT is just behind the best Puffin objective on both count metrics: 0.703 against 0.707 (Puffin + cosine) on DNase.
On the profile metrics the gains over BPNet are clear on three settings. Profile Pearson r rises from 0.438 to 0.505 on DNase, from 0.788 to 0.843 on ATAC, where it is the highest in the table, and from 0.462 to 0.512 on PRO-cap; profile JSD falls on the same three settings. SHIFT is not the best profile model, though: Puffin + cosine reaches 0.541 on PRO-cap, and the lowest JSD on ATAC is 0.337 (Puffin + cosine) against our 0.344. On ChIP-nexus the profile barely moves: a JSD of 0.695 against BPNet's 0.694, and a profile Pearson r of 0.248 against 0.246.
The answer to the task's question is therefore partly yes. SHIFT improves both kinds of metric over the reference objective on three settings and the count metrics on all of them. No method in the table, ours included, leads on both kinds at once.
How we got here
SHIFT was built in six promoted versions, each tested against the previous one on public base-resolution datasets that we prepared ourselves from several organisms, with held-out chromosomes kept sealed until the objective was frozen.
- The first comparison showed a trade-off, not a winner. We ran the reference objectives on two public assays. Weighting peaks equally improved count correlation on one of them, while the losses that emphasised profile shape often predicted totals poorly.
- Read pairs gave the first version. Our first objective used distinct read pairs to estimate how far profile variation exceeds sampling noise, and with the full model it improved all four metrics on two assays. On a three-track assay the profile gain was small; our read-pair diagnostic explained why: the inferred shape reliability at median depth was 0.86 on the first two assays but only 0.04 to 0.06 on the three tracks, so their profile metrics sit close to a sampling floor.
- No single task dominates the gradient. We measured the shared trunk gradients directly. On one assay the median count to profile norm ratio was 6.8 to 0.29 early in training; on another the profile gradient dominated. A fixed rebalancing in either direction is therefore wrong somewhere.
- Unconditional gradient equalisation was abandoned. Equalising the two tasks' gradients raised one assay's count Pearson r from 0.493 to 0.528 in development but lost profile accuracy on another, where the profile gradient was already much larger than the count gradient. This is why the final filter can only scale the count task down.
- The offset term came early; calibration stayed under test. Our second version separated the batch offset from the contrast, with an anchor weighted by the precision of the batch mean, and improved count correlations over the first version on several assays. A later development model ranked peaks better but over-predicted their mean log count by 0.35, and we went on to test corrections that use the uncertainty of the batch mean.
- Spatial smoothing of the targets hurt. An empirical-Bayes smoothing kernel improved the agreement between independent replicates of a sparse assay, but training the shared model with the kernel-marginalised score reduced its held-out profile Pearson r from 0.146 to 0.121, and we dropped it.
- Split-half filtering beat fixed weights. A controlled ablation showed that measuring the agreement of half-batch gradients helped beyond using the same loss terms with fixed weights.
- The information unit mostly moved counts. Dividing the profile term by raised count Pearson r from 0.442 to 0.493 on one development assay, with profile Pearson r slipping from 0.363 to 0.357, and had little effect on two others. An analytical reduced-rank regression study made the same point: task weights matter only when capacity is short, and then they trade one task against the other.
- The schedule helps, but it is not the method. The cosine recipe improved all four metrics on average over four assays with the objective held fixed. Against BPNet trained with the same schedule, our development comparison across seven assays still showed gains of 0.059 in count Pearson r, 0.041 in count Spearman ρ and 0.026 in profile Pearson r, and a JSD lower by 0.008.
We also consulted two works outside this task's reference list: the estimation of entropies under a Dirichlet prior, for the posterior expected KL, and a method that decouples order from scale in regression, which we read while exploring rank-based alternatives for the count term.
Limitations
- ChIP-nexus's profiles are untouched. Our profile JSD there is level with BPNet's and slightly above it, and the profile Pearson r is essentially unchanged. The gain on ChIP-nexus is in counts only. Our development diagnostics suggest a reason, profiles with very low reliability for which the weighting has little to work with, but we have not shown it on this setting.
- Not the best profile model. Shape-oriented objectives reach a higher profile Pearson r on PRO-cap, and some baseline has a lower profile JSD than ours on every setting. SHIFT gives up part of the attainable profile accuracy for count accuracy, which is what its filter is allowed to do.
- The reliability estimate assumes independent reads. In a final stress test we duplicated every read: the profiles stayed identical, but the estimated reliability rose (the median over tracks of the mean reliability went from 0.686 to 0.841). Libraries with many duplicate reads will be weighted as if they were deeper than they are.
- The count term ignores non-peak regions. It is fitted on peaks only, which suits metrics on held-out peaks but leaves the prediction of background totals untrained by the contrast.
- Part of the gain is the recipe. The cosine schedule and its learning rate were changed together with the objective. Our matched-schedule development comparison suggests the objective accounts for most of the gain, but that comparison was not repeated on this task's settings.
- The filter is tuned, not derived throughout. The probe interval of 24 steps, the 0.35 weight on non-peak profiles, the 0.35 count-scale floor and the selection criterion's normalisation are choices that development data supported, not consequences of the model.
References
- Žiga Avsec, Melanie Weilert, Avanti Shrikumar et al. (2021). Base-resolution models of transcription-factor binding reveal soft motif syntax. Nature Genetics.
- Anusri Pampari, Anna Shcherbina, Evgeny Z. Kvon et al. (2024). ChromBPNet: bias factorized, base-resolution deep learning models of chromatin accessibility reveal cis-regulatory sequence syntax, transcription factor footprints and regulatory variants. bioRxiv.
- Nuria Alina Chandra, Yan Hu, Jason D Buenrostro et al. (2026). Refining sequence-to-activity models by increasing model resolution. Bioinformatics Advances.
- Johannes Linder, Divyanshi Srivastava, Han Yuan et al. (2025). Predicting RNA-seq coverage from DNA sequence as a unifying model of gene regulation. Nature Genetics.
- Žiga Avsec, Natasha Latysheva, Jun Cheng et al. (2026). Advancing regulatory variant effect prediction with AlphaGenome. Nature.
- Kseniia Dudnyk, Donghong Cai, Chenlai Shi et al. (2024). Sequence basis of transcription initiation in the human genome. Science.
- Adam Y. He, Charles G. Danko (2024). Dissection of core promoter syntax through single nucleotide resolution modeling of transcription initiation. bioRxiv.
- Ozan Sener, Vladlen Koltun (2018). Multi-Task Learning as Multi-Objective Optimization. NeurIPS.
- Zhao Chen, Vijay Badrinarayanan, Chen-Yu Lee et al. (2018). GradNorm: Gradient Normalization for Adaptive Loss Balancing in Deep Multitask Networks. ICML.
- Tianhe Yu, Saurabh Kumar, Abhishek Gupta et al. (2020). Gradient Surgery for Multi-Task Learning. NeurIPS.
- Bo Liu, Xingchao Liu, Xiaojie Jin et al. (2021). Conflict-Averse Gradient Descent for Multi-task Learning. NeurIPS.
- Aviv Navon, Aviv Shamsian, Idan Achituve et al. (2022). Multi-Task Learning as a Bargaining Game. ICML.