In this post I attempt to formalize my thoughts on contemporary machine learning research for Type 1 Diabetes modeling and prediction. I dream of a day where an insulin pump can locally run a model of sufficient quality in a closed-loop system such that the most a patient has to think about their pump is refilling it or recharging it. I've kept notes and thoughts to myself for a long time, but I mean to do a better job of publishing what I've been obsessed with for the past few years.
Proposition (statistical learnability under clinical risk)
Let denote the blood-glucose value reported by a continuous glucose monitor sampled at (typically min), and let denote, respectively, bolus insulin delivery, basal insulin delivery, and carbohydrate intake at time . Fix a lookback horizon and a forecast horizon , and write
for the state window, with compact under physiological bounds. Glucose dynamics admit the Bergman minimal model
with insulin/carbohydrate forcing and remote insulin action . By Picard–Lindelöf together with an Itô-process embedding for the measurement noise, there exists a Borel-measurable conditional law
for the future trajectory given , of which the deterministic mean response is a single moment. The clinical problem demands the full conditional law, because the relevant losses are asymmetric and tail-sensitive — minimizing the mean-squared error in is not the right objective when the cost of being wrong is itself a sharply asymmetric function of .
Fix a clinical target band , taking the 2019 ATTD consensus values and mg/dL, and a severe-hypoglycemia threshold mg/dL. Define the clinical risk functional
convex, zero on the target band, and asymmetric in the direction of clinical reality — severe hypoglycemia is acutely lethal on a timescale of minutes, severe hyperglycemia is chronically expensive on a timescale of years. The form is in the spirit of the Kovatchev BG-Risk Index but reduced to a one-sided quadratic for analytical convenience. The full closed-loop objective for any meal/correction policy and stabilizing basal estimator is then
with , a confidence level (e.g., 0.99), and . The first term penalizes deviation from the target band asymmetrically; the second bounds the expected severity of the worst fraction of hypoglycemic excursions — the formal statement of "a closed-loop controller that does not kill its user". The minimum of is the clinical Bayes risk — strictly tail-aware, and a strictly stronger guarantee than Bayes risk on alone.
Let be a sufficiently expressive parametric family of conditional generators — diffusion or flow-matched models with MLP / transformer / state-space score networks, or quantized autoregressive heads — capable of modeling rather than only its mean. By Hornik–Cybenko-style universal approximation of the score/drift function on compact , lifted to distribution approximation in 2-Wasserstein, for every there exists with
Both (locally Lipschitz on the physiological range) and (1-Lipschitz in , hence continuous in ) are continuous functionals of the conditional law under . Convergence of to in therefore implies convergence of to its infimum, and the empirical-risk minimizer of on samples is consistent on . Hence forecasting, bolusing, and basal control on are statistically learnable under clinical risk and safety: in the population limit, the closed-loop policy achieves the clinical Bayes risk and the -bounded hypoglycemia constraint simultaneously.
Whether the joint problem is additionally PAC-learnable — whether a tractable hypothesis class of conditional generators exists with VC dimension or empirical Rademacher complexity growing slowly enough in to deliver uniform convergence of the risk-aware empirical loss
with high probability — is the open question I am currently working out.
Remark (modification). The Bergman ODE is autonomous in its coefficients while the human is not. Insulin sensitivity exhibits a circadian profile, dawn phenomenon in the early morning, blunted sensitivity in the evening, and acute sympathetic activity shifts hepatic glucose production and peripheral glucose uptake on minute scales. Both are unobserved confounders relative to , inflating the predictive variance above its physical lower bound. Augmenting the state with time-of-day , encoded as , and heart rate strictly tightens this floor: by the law of total variance,
and the subtracted term is strictly positive unless — a conditional-independence statement the physiology rules out. The expected conditional variance under the augmented state is therefore strictly smaller than under alone, the conditional law concentrates correspondingly tighter, and inherits a strictly lower achievable floor.
Remark (architecture). Attention is the right inductive bias here: meal absorption, insulin pharmacokinetics, and exercise effects each induce variable-lag couplings between events in and future , and softmax attention
learns these data-dependent kernels without committing to a fixed convolutional receptive field or recurrent memory horizon. Yet existing CGM transformers underexplore the embedding space: heterogeneous tokens — scalar glucose , sparse event-valued carb intake , cyclic , dense — are typically projected through a single shared linear lift , collapsing the inductive priors that distinguish them. Fourier features on , event-typed embeddings on , and separate continuous streams for with cross-attention fusion are the obvious levers, and remain largely untouched in the published literature.
Remark (existing work). Two recent results bracket the proposition. GluFormer (Lutsker et al., 2024, arXiv:2408.11876) trains an autoregressive transformer on over CGM measurements from 10,812 adults and shows that the learned representation generalizes across 19 cohorts, 5 countries, and 8 devices — outperforming HbA1c on 12-year diabetes-onset risk stratification. As evidence that admits a useful low-dimensional summary, this is dispositive: the foundation-model paradigm is viable on CGM at population scale. As a candidate for the closed-loop claim, it is misaligned on three counts. First, the training cohort is primarily non-diabetic — a glycemic regime governed by endogenous β-cell response, not by exogenous bolus pharmacokinetics. The covariate shift to T1D is exactly the regime where dominate , and where prediction errors are most clinically expensive. Second, the architecture is glucose-only autoregression; insulin and carbohydrates enter only through a separately trained multi-modal variant, and neither version conditions on as causal forcing terms. Third, glucose tokenization — necessary for the LM-style decoder — discards the continuous metric structure any downstream control law has to reason over.
The hybrid GRU–Transformer of Mazgouti et al. (2026, Algorithms 19(1):52) cuts the other way: small, narrow, but architecturally adjacent to what the proposition wants. A 60-step lookback at min, augmented with hand-engineered features (entropy, detrended fluctuation analysis, monotonicity, sinusoidal time-of-day), yields reported 30-/60-min RMSEs of 6.65 / 8.91 mg/dL on a 12-patient T1D cohort — striking relative to the OhioT1DM literature, which clusters in the 15–22 mg/dL range at 30 min. The intuition is right: short-range recurrence composes with global attention to span the meal-response and circadian scales the Bergman model predicts. But the experimental frame is doing work the architecture is not. The cohort is on a single Freestyle Libre at 15-min sampling (vs. 5-min for current Dexcom G7, 1-min for Libre 3), Savitzky–Golay smoothing is applied to the full CGM signal prior to windowing, which smooths both the model inputs and the effective prediction targets, and the inputs exclude . The model therefore forecasts the autonomous evolution of , not the controlled response to insulin and carbs. Each restriction strictly shrinks the regression problem; none is admissible under the proposition.
Remark (direction). The architectural remark above identifies the right relational primitive — variable-lag, data-dependent coupling — but not the right computational or segmentation primitive for the data regime the proposition actually demands. Softmax attention's cost forces the windowed lookback that essentially every published CGM transformer relies on, and rules out the natural training context: months of per-patient 5-min CGM plus event-typed insulin and carb streams, on the order of tokens per patient before any multi-patient pretraining. Structured state-space models like Mamba-2 in particular (Dao & Gu, 2024, arXiv:2405.21060) recover inference under a state-space duality that makes the recurrence 2–8× faster than the original Mamba while remaining competitive with transformers on long-sequence modeling. They are the obvious backbone once context length is no longer a budgeting decision. Their theoretical and experimental gains have been demonstrated on language and DNA; the work that remains is showing the same gains transfer to the CGM regime, where the relevant baseline is not perplexity but the clinical-risk objective above.
The deeper mismatch is hierarchical. A T1D timeline is not a uniform sequence: information density spikes at meals, boluses, and exercise, and is near-zero across overnight steady states. Fixed-stride tokenization spends capacity on the idle hours and underresolves the events that drive . H-Net (Hwang, Wang & Gu, 2025, arXiv:2507.07955) targets exactly this: a learned dynamic chunking operator, trained jointly with the rest of the network, that replaces tokenization with content- and context-dependent segmentation. A byte-level H-Net using Mamba-2 encoder/decoder blocks with a Transformer main network matches a token-based transformer of twice its size on language and achieves nearly data efficiency on DNA, a continuous biosensor stream with event-driven structure and no natural token boundaries, which is structurally the regime CGM lives in. An H-Net variant with (i) event-typed embeddings for in place of byte embeddings, (ii) a continuous regression head on in place of softmax over a discretized vocabulary, and (iii) chunk-boundary supervision tied to detected meal/insulin/exercise events is the architecture I am currently working out.
This framing dovetails with Large Concept Models (Barrault et al., 2024, arXiv:2412.08821), which abandon next-token prediction entirely in favor of next-concept prediction in a sentence-embedding space — a sequence roughly an order of magnitude shorter than the underlying tokens, generated either by MSE regression on the embedding or by diffusion over it. The analogy to T1D is almost too clean: the dynamic chunks H-Net would learn over are not "tokens" in any meaningful sense; they are pharmacokinetic events. A bolus is a concept with a known onset–peak–duration profile parameterized by the insulin analog. A meal is a concept with a carbohydrate-rate absorption profile dependent on macronutrient composition and gastric emptying. An exercise bout is a concept with a sympathetic-burst signature followed by sustained peripheral glucose uptake. A nocturnal basal regime is a concept whose evolution is governed by hepatic glucose production and the dawn cortisol rise. Each admits a low-dimensional latent description, and the patient's day decomposes into a sequence of such concepts plus the inter-event dynamics of between them.
A "large pharmacokinetic concept model" — H-Net's dynamic chunker producing event-segmented embeddings, a Mamba-2 backbone advancing the sequence of event embeddings, and an LCM-style head predicting the next event embedding — has two structural advantages over flat next-sample autoregression of . First, the effective reasoning horizon shortens by roughly the average inter-event interval: a multi-day context collapses from samples to event tokens, which is precisely the LCM compression argument transposed onto physiology. Second, the right modeling primitive at the event level is distributional, not pointwise. The LCM team motivates diffusion over MSE because a given context may have many plausible, yet semantically different, continuations; in T1D, given identical , the next-event distribution is multimodal as the same pre-meal state can be followed by a 40 g carbohydrate intake or by a stress-driven hepatic glucose surge, and the lower tail of the predictive distribution is where hypoglycemia lives. A diffusion or quantized head over event-embedding space directly targets the conditional law that the proposition demands: it produces samples from which both the asymmetric clinical risk and the severe-hypo tail penalty in are empirically computable, and against which the policy and basal estimator can be optimized end-to-end. This is the modeling primitive the clinical-risk formulation explicitly requires; pointwise approximators of cannot resolve the lower tail of the predictive distribution, and the lower tail is the safety-critical object. The SSM/H-Net/LCM stack is the obvious vehicle for it.
Why is it obvious?
The short answer is inference cost. A transformer's attention mechanism computes a similarity score between every pair of positions in its input window — if the window has tokens, that's comparisons. Double the context, quadruple the compute. This is fine when you have a GPU cluster and are in no hurry; it is fatal when your inference budget is a coin-cell battery clipped to a belt. More precisely, at inference time, a transformer must retrieve and attend over its entire key-value cache on every new prediction: each fresh 5-minute glucose sample forces a pass over every prior sample in the window, so compute grows with context length even after training is done. A structured state-space model like Mamba-2 works differently: it compresses all prior history into a fixed-size hidden state (a compact summary vector) and updates that state with each new observation in constant time, per step regardless of how long the patient has been wearing the device. The full-history context that makes SSMs expensive to train (you still process the sequence once) becomes essentially free at inference time, because the recurrent state update costs the same whether you are processing sample 1 or sample 100,000. For a closed-loop insulin pump, this distinction is the whole ballgame. A modern pump like the Omnipod 5 or Tandem t:slim X2 runs on a microcontroller in a device worn directly against skin, with a battery measured in milliamp-hours, inside a thermal envelope where sustained heat generation means a burn, not a throttle warning. An attention-based model forecasting over weeks of 5-minute CGM history cannot run there, not because the arithmetic is hard, but because the arithmetic is quadratically too much of it. An SSM-based model, updating a fixed hidden state every five minutes, can.
The physics of this system is one of the biggest constraints. A majority of these model developments are happening inside environments of massive power and thermal capability: GPU data centers measured in hundreds of megawatts, with hot-aisle exhaust pushing 50°C. Whatever model is capable of managing diabetes to near perfection must also be capable of running inference inside a device that draws single-digit milliwatts, dissipates heat into the body it is trying to protect, and has no connection to a server. The gap between where these models are currently developed and where they eventually need to run is somewhere around eight to ten orders of magnitude in power budget. That is not a gap you close by waiting for Moore's Law. It is a gap you close by choosing the right architecture and by treating on-device deployability as a first-class design constraint rather than an afterthought for the productization team.