Skip to Content
OchreML
Architecture & Benchmarks

.dit Binary Format Specification

Specification of OchreML's DIT\x01 binary serialization format, cross-device loading, and additive tag registry.

OchreML persists trained models, preprocessors, and deep learning architectures to compact .dit files using a custom zero-dependency binary format (DIT\x01). Models trained on one device (for example, cuda:all or tpu:0) can be saved to .dit and reloaded on any other device (cpu, wgpu, cuda:0) without retraining. (*≧ω≦*)

Binary Header Layout

Every native .dit file begins with a 5-byte header followed by a deterministic little-endian binary payload specific to the model tag:

Byte OffsetSizeFieldValue / Description
0..44 bytesMagic + VersionASCII DIT followed by version byte 0x01 (b"DIT\x01")
41 bytetag (u8)Additive model type identifier (1..98 Classical ML & Preprocessing, 100..102 ochreml.nn)
5..EOFvariablePayloadLittle-endian model weights, hyperparameters, feature metadata, and learned state

Compatibility & Extension Guarantees

  • Strict .dit extension: ochreml.save() and ochreml.load() validate that paths end with .dit (case-insensitive).
  • Additive tag numbering: Existing TAG_* IDs are never reassigned or reused, ensuring .dit artifacts saved by older versions remain readable in newer releases.
  • Archive fallback: If a .dit file does not start with DIT\x01 (for example, a custom Python Pipeline containing user-defined functions), ochreml.load() transparently falls back to joblib / pickle and applies .to(device) if requested.

Saving, Loading & Inspecting

import ochreml
from ochreml.linear_model import Ridge

model = Ridge(alpha=0.5, device="cuda:0").fit(X_train, y_train)
ochreml.save(model, "ridge_v1.dit")

# Reload on CPU for lightweight edge/server inference
cpu_model = ochreml.load("ridge_v1.dit", device="cpu")
preds = cpu_model.predict(X_test)

You can also inspect or verify .dit files from the terminal without writing Python:

ochreml inspect ridge_v1.dit
ochreml verify ridge_v1.dit

Storage & Speed vs. Pickle / Joblib

Measured on v0.3.7a1 (cpu_4c and cuda_2gpu benchmark suites):

Model.dit SizePickle / Joblib Size.dit Save (CPU 4c).dit Load (CPU 4c).dit Save (2xGPU).dit Load (2xGPU)
Ridge0.29 KB0.34–0.35 KB0.197 ms0.626 ms0.111 ms0.349 ms
LogisticRegression0.43–0.44 KB0.54–0.55 KB0.131 ms0.401 ms0.071 ms0.557 ms
StandardScaler0.44–0.45 KB0.52 KB0.083 ms0.672 ms0.074 ms0.371 ms
HistGradientBoostingRegressor30.94 KB31.04–31.05 KB0.230 ms0.761 ms0.136 ms0.417 ms
RandomForestClassifier163.25 KB (4c) / 248.27 KB (2xGPU)163.33 KB / 248.34 KB0.248 ms0.713 ms0.281 ms0.861 ms

Complete DIT\x01 Tag Registry

Classical ML Core & Linear (1–6, 38–42, 49–55)

TagClassTagClassTagClass
1LinearRegression38LogisticRegression50QuantileRegressor
2DecisionTreeClassifier39Lasso51PoissonRegressor
3DecisionTreeRegressor40ElasticNet52GammaRegressor
4Ridge41SGDClassifier53TweedieRegressor
5RidgeClassifier42SGDRegressor54LinearSVC
6RidgeCV49HuberRegressor55LinearSVR

Preprocessing, Imputation, Feature Extraction & Compose (7–37)

TagClassTagClassTagClass
7StandardScaler18SplineTransformer29FeatureHasher
8MinMaxScaler19OneHotEncoder30CountVectorizer
9MaxAbsScaler20OrdinalEncoder31TfidfTransformer
10RobustScaler21LabelEncoder32TfidfVectorizer
11Normalizer22LabelBinarizer33HashingVectorizer
12Binarizer23MultiLabelBinarizer34IterativeImputer
13KernelCenterer24TargetEncoder35FunctionTransformer
14PolynomialFeatures25SimpleImputer36ColumnTransformer
15KBinsDiscretizer26MissingIndicator37TransformedTargetRegressor
16PowerTransformer27KNNImputer
17QuantileTransformer28DictVectorizer

Decomposition, Clustering, Neighbors, Naive Bayes, Ensembles, Kernels & Selection (43–48, 56–98)

TagClassTagClassTagClass
43PCA64GaussianMixture82MLPRegressor
44TruncatedSVD65HistGradientBoostingClassifier83GaussianProcessRegressor
45LinearDiscriminantAnalysis66HistGradientBoostingRegressor84GaussianProcessClassifier
46QuadraticDiscriminantAnalysis67RandomForestClassifier85DBSCAN
47KMeans68RandomForestRegressor86OPTICS
48MiniBatchKMeans69ExtraTreesClassifier87SpectralClustering
56KNeighborsClassifier70ExtraTreesRegressor88AgglomerativeClustering
57KNeighborsRegressor71GradientBoostingClassifier89LocalOutlierFactor
58RadiusNeighborsClassifier72GradientBoostingRegressor90NMF
59RadiusNeighborsRegressor73AdaBoostClassifier91CCA
60GaussianNB74AdaBoostRegressor92PLSRegression
61MultinomialNB75IsolationForest93TSNE
62BernoulliNB76SVC94MDS
63ComplementNB77SVR95RBFSampler
78OneClassSVM96VarianceThreshold
79KernelRidge97SelectKBest
80KernelPCA98SelectPercentile
81MLPClassifier

Deep Learning (ochreml.nn, 100–102)

TagClassDescription
100ochreml.nn.SequentialSequential neural network architecture & weights
101ochreml.nn.CausalLMAutoregressive Transformer / Causal Language Model
102ochreml.nn.LoRAAdapterStateLow-Rank Adaptation (W + B * A) adapter weights

On this page