Northstar: forecast demand before committing inventory
Forecast hourly order demand with NV-Tesseract, retrieval-enhanced DARR and simple baselines before committing inventory.
Casebook links: RET-01 / RET-09 · Real pretrained model · Synthetic data · Rolling-origin evaluation
A category planner needs the next three days of hourly order demand. Under-ordering loses service; over-ordering ties up stock. Can a pretrained model beat a same-hour-yesterday rule, and does historical retrieval help?
The saved example compares persistence, daily seasonality, direct NV-Tesseract forecasting, and DARR context-enhanced forecasting on three predeclared nonoverlapping future blocks. It then compares decisions when shortages cost more than excess capacity.
Prerequisites and support
Section titled “Prerequisites and support”Dependency-incomplete download: this .ipynb preserves the lesson and its saved outputs, but is not a standalone runnable package. It does not include time_series_lab.py, time_series_prepare.py, time-series-model-lock.json, mementropy.mplstyle, the pinned upstream SDK checkout, or model assets. There is no verified public support bundle or locked Python environment for this download. Installing Jupyter alone will not make Run All work.
The original setup used Python 3.12 with Jupyter/IPython, NumPy, pandas, Matplotlib, PyTorch and the matching upstream SDK dependencies. Forecasting cells use pandas’ include_groups API (pandas 2.2 or later). These are prerequisites, not a tested installation recipe. The missing helper expected upstream code under .runtime/NV-Tesseract and model-family asset directories beside it. Its preparation step downloads assets; its activation step checks revisions and hashes before loading. The forecasting and anomaly packages share the sdk namespace and require separate fresh kernels.
Retained identities for an independently reviewed reconstruction:
- Upstream NVIDIA/NV-Tesseract, revision
7fa53ac50abcd8829550d9399875f24170c1d0e8. - Forecasting model:
nvidia/nv-tesseract-forecasting, revisionabff20a58834638b28227ff4ab934f26206e4b09; required files includerun8_best_model_cr.ptandstandardizer.pkl. - Backbone:
AutonLab/MOMENT-1-large, revisionca58581bc7bea2ebed4e80dc0a3e4b8b609c6ecc; required files includeconfig.jsonandmodel.safetensors.
Use the official source and model cards linked below to review licenses, hardware support and security requirements before acquiring assets. Checkpoint and standardizer loading can deserialize code-capable formats; verify provenance and hashes in a disposable environment. The public download includes no weights or credentials. A complete helper distribution, dependency lock and clean-environment smoke test remain unverified; this page does not offer a one-command rerun.
Evidence: these are saved outputs from an earlier execution, not rerun for the 2026-10-29 editorial update. Rendering displays saved cells; it does not execute them. The public download is not a locked environment or a production validation.
from pathlib import Pathimport sys, time, json, hashlibimport numpy as npimport pandas as pdimport matplotlib.pyplot as pltfrom IPython.display import display, Markdown, JSON# Requires the separately prepared runtime described above; the public download is dependency-incomplete.from time_series_lab import activate, features, anomaly_metrics, style, LOCK, RUNTIMEstyle()weights = activate('forecast')import torchfrom dataclasses import replacefrom sdk.forecasting import ForecastingConfig, perform_forecastingDEVICE = 'mps' if torch.backends.mps.is_available() else 'cuda' if torch.cuda.is_available() else 'cpu'print({'model': 'NV-Tesseract Forecasting', 'device': DEVICE, 'checkpoint_revision': LOCK['forecast']['revision'], 'backbone_revision': LOCK['backbone']['revision']}){'model': 'NV-Tesseract Forecasting', 'device': 'mps', 'checkpoint_revision': 'abff20a58834638b28227ff4ab934f26206e4b09', 'backbone_revision': 'ca58581bc7bea2ebed4e80dc0a3e4b8b609c6ecc'}
Build a dataset with business structure
Section titled “Build a dataset with business structure”This fixture has hourly seasonality, a weekly cycle, trend, correlated workload signals, and random noise. It is not a real retailer or bank extract. A reproducible synthetic fixture lets us inspect the mechanics without exposing customer records; it does not establish real-world generalization.
rng = np.random.default_rng(23)t = np.arange(1500)daily = np.sin(2*np.pi*t/24 - .5)weekly = np.cos(2*np.pi*t/168)values = 100 + 28*daily + 12*weekly + .012*t + rng.normal(0,4,len(t))df = pd.DataFrame({ 'timestamp': pd.date_range('2026-01-01', periods=len(t), freq='h'), 'orders_per_hour': values, 'activity_index': 50 + 12*daily + 6*weekly + rng.normal(0,1,len(t)), 'upstream_volume': 200 + 35*daily + .02*t + rng.normal(0,3,len(t)),})TARGET = 'orders_per_hour'columns = [TARGET, 'activity_index', 'upstream_volume']features(df, columns) # Reject missing data, duplicate/out-of-order timestamps and labels.origins = [1280, 1352, 1424]HORIZON = 72assert all(b-a >= HORIZON for a,b in zip(origins,origins[1:]))fig, ax = plt.subplots(figsize=(11,4))ax.plot(df.timestamp, df[TARGET], linewidth=.8)for origin in origins: ax.axvspan(df.timestamp[origin], df.timestamp[origin+HORIZON-1], alpha=.12)ax.set(title='Synthetic workload and three predeclared future blocks', ylabel=TARGET.replace('_',' '))plt.tight_layout(); plt.show()display(df.head())| timestamp | orders_per_hour | activity_index | upstream_volume | |
|---|---|---|---|---|
| 0 | 2026-01-01 00:00:00 | 100.789127 | 50.065803 | 186.679219 |
| 1 | 2026-01-01 01:00:00 | 106.267287 | 53.579933 | 188.706129 |
| 2 | 2026-01-01 02:00:00 | 112.419190 | 55.310237 | 207.775588 |
| 3 | 2026-01-01 03:00:00 | 110.567909 | 60.236967 | 208.237108 |
| 4 | 2026-01-01 04:00:00 | 128.208235 | 62.641313 | 217.712561 |
Draw the information boundary
Section titled “Draw the information boundary”At each origin, the model receives only the preceding 512 observations. DARR’s retrieval library ends before that input window starts, so its historical continuations cannot contain held-out future values. The supplied checkpoint and standardizer are frozen; we do not fit them on this fixture. Past auxiliary channels are available, but future auxiliary values are never provided.
The model’s native head is 72 points. We keep sequence length 512 and horizon 72, use three forecast origins, and fix DARR at 20% direct forecast / 80% historical retrieval before looking at errors.[2] This is a small demonstration, not hyperparameter optimization. Sequential forecast blocks emulate later decision times: once a block becomes history it is legitimately observable at the next origin.
config = ForecastingConfig( target_column=TARGET, seq_len=512, forecast_horizon=HORIZON, model_horizon=72, ckpt=str(weights/'run8_best_model_cr.pt'), standardizer_pkl=str(weights/'standardizer.pkl'), model_name=str(RUNTIME/'backbone'), local_files_only=True, device=DEVICE, num_workers=0, batch_size=4, use_cross_channel=True, alpha=.2, k=4, context_stride=72, seed=42,)rows, timings = [], []for origin in origins: history = df.iloc[origin-512:origin].copy() context = df.iloc[:origin-512].copy() future = df.iloc[origin:origin+HORIZON].copy() assert context.timestamp.max() < history.timestamp.min() < future.timestamp.min() assert history.timestamp.max() < future.timestamp.min() started = time.perf_counter() direct = perform_forecasting(df=history, config=config) darr = perform_forecasting(df=history, config=config, context_df=context) timings.append(time.perf_counter()-started) assert direct.timestamp.tolist() == future.timestamp.tolist() assert darr.timestamp.tolist() == future.timestamp.tolist() predictions = { 'Persistence': np.repeat(history[TARGET].iloc[-1], HORIZON), 'Daily seasonal': np.tile(history[TARGET].iloc[-24:].to_numpy(), 3), 'NV-Tesseract direct': direct[f'{TARGET}_forecast'].to_numpy(), 'NV-Tesseract DARR': darr[f'{TARGET}_forecast'].to_numpy(), } for method, prediction in predictions.items(): assert len(prediction) == HORIZON and np.isfinite(prediction).all() rows.extend({'origin': origin, 'timestamp': timestamp, 'method': method, 'actual': float(actual), 'prediction': float(predicted)} for timestamp,actual,predicted in zip(future.timestamp, future[TARGET], prediction))results = pd.DataFrame(rows)print(f'Executed {len(origins)} origins, two model modes per origin, on {DEVICE}.')print('Seconds per origin (includes cold loading at the first origin):', np.round(timings,2).tolist())Loading weights from local directory
UserWarning: Only reconstruction head is pre-trained; others need fine-tuning.
Executed 3 origins, two model modes per origin, on mps. Seconds per origin (includes cold loading at the first origin): [6.72, 0.24, 0.27]
Read the forecast, not just a headline score
Section titled “Read the forecast, not just a headline score”MAE averages absolute errors; WAPE divides total absolute error by total actual volume. Report all origins, not the prettiest one. No claim about model superiority is required for this notebook to succeed: an honest baseline win is useful evidence.
results['absolute_error'] = (results.prediction-results.actual).abs()metrics = results.groupby('method').apply(lambda group: pd.Series({ 'MAE': group.absolute_error.mean(), 'WAPE_pct': 100*group.absolute_error.sum()/group.actual.abs().sum(),}), include_groups=False).sort_values('MAE')display(metrics.round(3))display(results.groupby(['origin','method']).absolute_error.mean().unstack().round(2))first = results[results.origin == origins[0]]fig, ax = plt.subplots(figsize=(11,5))actual = first[first.method=='Persistence']ax.plot(actual.timestamp, actual.actual, color='#171817', linewidth=2, label='Actual future (evaluation only)')for method in ['Daily seasonal', 'NV-Tesseract direct', 'NV-Tesseract DARR']: subset = first[first.method==method] ax.plot(subset.timestamp, subset.prediction, label=method)ax.set(title='First forecast block — every method faces the same unseen future', ylabel=TARGET.replace('_',' '))ax.legend(fontsize=9); plt.tight_layout(); plt.show()| MAE | WAPE_pct | |
|---|---|---|
| method | ||
| NV-Tesseract direct | 8.357 | 7.145 |
| NV-Tesseract DARR | 8.579 | 7.334 |
| Daily seasonal | 13.585 | 11.614 |
| Persistence | 28.470 | 24.339 |
| method | Daily seasonal | NV-Tesseract DARR | NV-Tesseract direct | Persistence |
|---|---|---|---|---|
| origin | ||||
| 1280 | 17.40 | 11.68 | 9.01 | 20.31 |
| 1352 | 13.76 | 7.81 | 8.36 | 38.88 |
| 1424 | 9.59 | 6.24 | 7.70 | 26.23 |
Turn error into an operating decision
Section titled “Turn error into an operating decision”The business decision is units of inventory, not a low error score. For illustration, count each unit of underprediction as four cost units and overprediction as one. These are assumptions, not measured dollars, service-level guarantees, or an inventory/queueing optimization. We clip negative predictions to zero only for this nonnegative capacity decision, not to improve the reported forecast MAE.
Compare a declared 10% planning buffer with no buffer. This teaches the separation between a statistical forecast and a decision policy. Do not select a buffer on these test results and then describe its savings as out-of-sample.
policies = []for buffer in [0., .10]: planned = results.prediction.clip(lower=0)*(1+buffer) shortage = (results.actual-planned).clip(lower=0) excess = (planned-results.actual).clip(lower=0) scored = results.assign(cost=4*shortage+excess, shortage=shortage) table = scored.groupby('method')[['cost','shortage']].sum() table['buffer_pct'] = int(buffer*100) policies.append(table.reset_index())policy_table = pd.concat(policies, ignore_index=True)display(policy_table.round(2))fig, ax = plt.subplots(figsize=(11,4))policy_table.pivot(index='method',columns='buffer_pct',values='cost').plot.barh(ax=ax)ax.set(title='Toy asymmetric cost: forecast choice and planning buffer both matter', xlabel='Assumed cost units')ax.legend(title='Buffer %'); plt.tight_layout(); plt.show()best = metrics.index[0]lowest_cost = policy_table.sort_values('cost').iloc[0]display(Markdown(f"**Decision insight:** the lowest assumed cost is {lowest_cost['method']} with a {int(lowest_cost['buffer_pct'])}% buffer. The MAE winner is {best}. These answer different questions: how close is the forecast, and what does the proposed action cost? This is exploratory policy comparison, not validated savings."))display(Markdown(f"**Observed:** {best} has the lowest aggregate MAE on these three synthetic blocks. " "Use the origin-level table to check consistency. " "DARR retrieval is worth investigating only if it adds value beyond simple seasonality and its compute cost. " "Carry the declared loss function into a separate real-data validation, rather than promising savings from this toy run."))| method | cost | shortage | buffer_pct | |
|---|---|---|---|---|
| 0 | Daily seasonal | 8466.72 | 1844.12 | 0 |
| 1 | NV-Tesseract DARR | 6907.28 | 1684.76 | 0 |
| 2 | NV-Tesseract direct | 4394.14 | 862.99 | 0 |
| 3 | Persistence | 7201.46 | 350.64 | 0 |
| 4 | Daily seasonal | 5538.63 | 768.25 | 10 |
| 5 | NV-Tesseract DARR | 2991.03 | 426.51 | 10 |
| 6 | NV-Tesseract direct | 3179.50 | 113.15 | 10 |
| 7 | Persistence | 8845.56 | 65.17 | 10 |
Decision insight: the lowest assumed cost is NV-Tesseract DARR with a 10% buffer. The MAE winner is NV-Tesseract direct. These answer different questions: how close is the forecast, and what does the proposed action cost? This is exploratory policy comparison, not validated savings.
Observed: NV-Tesseract direct has the lowest aggregate MAE on these three synthetic blocks. Use the origin-level table to check consistency. DARR retrieval is worth investigating only if it adds value beyond simple seasonality and its compute cost. Carry the declared loss function into a separate real-data validation, rather than promising savings from this toy run.
What breaks when the world changes?
Section titled “What breaks when the world changes?”A forecast is conditional on the patterns it can observe. Reuse the already frozen predictions against a counterfactual 40% workload surge; no model sees the surge beforehand. This is a stress test, not a second independent accuracy benchmark. It makes the operational limitation visible without cherry-picking a nicer model run.
shock = results.copy()shock['actual'] *= 1.4stress = shock.groupby('method').apply(lambda group: (group.prediction-group.actual).abs().mean(), include_groups=False)display(pd.DataFrame({'original_MAE': metrics.MAE, 'unannounced_surge_MAE': stress}).round(2))assert np.array_equal(shock.prediction.to_numpy(), results.prediction.to_numpy())print('Predictions remained frozen; only the synthetic counterfactual outcomes changed.')| original_MAE | unannounced_surge_MAE | |
|---|---|---|
| method | ||
| Daily seasonal | 13.59 | 50.39 |
| NV-Tesseract DARR | 8.58 | 53.81 |
| NV-Tesseract direct | 8.36 | 46.44 |
| Persistence | 28.47 | 31.73 |
Predictions remained frozen; only the synthetic counterfactual outcomes changed.
What to carry into a real pilot
Section titled “What to carry into a real pilot”- Use the actual forecast decision time to decide which inputs are legal. A timestamp split alone is insufficient if retrieval includes future continuations.
- Keep persistence and seasonal baselines. Complexity needs a measured benefit.
- Backtest across many origins, peak periods, and segments; reserve an untouched final interval for policy selection validation.
- Use domain owners to set shortage/excess costs and escalation rules. The model must not automatically order stock, schedule staff, move funds, or change customer decisions.
- These plots do not measure realized margin, staffing savings, fraud reduction, or production reliability. Record those separately in a human-reviewed pilot.
The receipt below comes from the actual run.
display(JSON({'case_id': 'RET-01 / RET-09', 'model': 'nvidia/nv-tesseract-forecasting', 'device': DEVICE, 'origins': origins, 'horizon': HORIZON, 'seconds': [round(value,3) for value in timings], 'protocol': 'rolling-origin-disjoint-retrieval', 'metrics': metrics.to_dict(orient='index'), 'decision_policies': policy_table.to_dict(orient='records')})){
"case_id": "RET-01 / RET-09",
"decision_policies": [
{
"buffer_pct": 0,
"cost": 8466.72173479142,
"method": "Daily seasonal",
"shortage": 1844.1162630566853
},
{
"buffer_pct": 0,
"cost": 6907.277573252261,
"method": "NV-Tesseract DARR",
"shortage": 1684.7593712786922
},
{
"buffer_pct": 0,
"cost": 4394.144440167894,
"method": "NV-Tesseract direct",
"shortage": 862.988581148635
},
{
"buffer_pct": 0,
"cost": 7201.455798176975,
"method": "Persistence",
"shortage": 350.6418256016484
},
{
"buffer_pct": 10,
"cost": 5538.631511850134,
"method": "Daily seasonal",
"shortage": 768.2477191175927
},
{
"buffer_pct": 10,
"cost": 2991.027031943494,
"method": "NV-Tesseract DARR",
"shortage": 426.51195771908687
},
{
"buffer_pct": 10,
"cost": 3179.499969113613,
"method": "NV-Tesseract direct",
"shortage": 113.1479652886086
},
{
"buffer_pct": 10,
"cost": 8845.563213305993,
"method": "Persistence",
"shortage": 65.17068426340106
}
],
"device": "mps",
"horizon": 72,
"metrics": {
"Daily seasonal": {
"MAE": 13.585059933432232,
"WAPE_pct": 11.613742916177195
},
"NV-Tesseract DARR": {
"MAE": 8.578701201000856,
"WAPE_pct": 7.3338528347554375
},
"NV-Tesseract direct": {
"MAE": 8.357308781120317,
"WAPE_pct": 7.144586489175661
},
"Persistence": {
"MAE": 28.47004778412977,
"WAPE_pct": 24.338782264954425
}
},
"model": "nvidia/nv-tesseract-forecasting",
"origins": [
1280,
1352,
1424
],
"protocol": "rolling-origin-disjoint-retrieval",
"seconds": [
6.716,
0.245,
0.267
]
}
Sources and scope
Section titled “Sources and scope”The source article frames forecasting as one task in a purpose-built model family.[1] This notebook uses NVIDIA’s later public forecasting release: a MOMENT-based backbone with a trained forecasting head and optional DARR retrieval from historical windows.[2][3] Neither the synthetic fixture nor the MAE/cost results here reproduce NVIDIA’s benchmarks. The model card labels the model for research and development.[3] No classification checkpoint is assumed. These are original teaching extensions of the enterprise casebooks, not completed enterprise implementations.
Sources
Section titled “Sources”[1] https://developer.nvidia.com/blog/new-nvidia-nv-tesseract-time-series-models-advance-dataset-processing-and-anomaly-detection — New NVIDIA NV-Tesseract Time Series Models Advance Dataset Processing and Anomaly Detection