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 Offset | Size | Field | Value / Description |
|---|---|---|---|
0..4 | 4 bytes | Magic + Version | ASCII DIT followed by version byte 0x01 (b"DIT\x01") |
4 | 1 byte | tag (u8) | Additive model type identifier (1..98 Classical ML & Preprocessing, 100..102 ochreml.nn) |
5..EOF | variable | Payload | Little-endian model weights, hyperparameters, feature metadata, and learned state |
Compatibility & Extension Guarantees
- Strict
.ditextension:ochreml.save()andochreml.load()validate that paths end with.dit(case-insensitive). - Additive tag numbering: Existing
TAG_*IDs are never reassigned or reused, ensuring.ditartifacts saved by older versions remain readable in newer releases. - Archive fallback: If a
.ditfile does not start withDIT\x01(for example, a custom PythonPipelinecontaining user-defined functions),ochreml.load()transparently falls back tojoblib/pickleand 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.ditStorage & Speed vs. Pickle / Joblib
Measured on v0.3.7a1 (cpu_4c and cuda_2gpu benchmark suites):
| Model | .dit Size | Pickle / Joblib Size | .dit Save (CPU 4c) | .dit Load (CPU 4c) | .dit Save (2xGPU) | .dit Load (2xGPU) |
|---|---|---|---|---|---|---|
Ridge | 0.29 KB | 0.34–0.35 KB | 0.197 ms | 0.626 ms | 0.111 ms | 0.349 ms |
LogisticRegression | 0.43–0.44 KB | 0.54–0.55 KB | 0.131 ms | 0.401 ms | 0.071 ms | 0.557 ms |
StandardScaler | 0.44–0.45 KB | 0.52 KB | 0.083 ms | 0.672 ms | 0.074 ms | 0.371 ms |
HistGradientBoostingRegressor | 30.94 KB | 31.04–31.05 KB | 0.230 ms | 0.761 ms | 0.136 ms | 0.417 ms |
RandomForestClassifier | 163.25 KB (4c) / 248.27 KB (2xGPU) | 163.33 KB / 248.34 KB | 0.248 ms | 0.713 ms | 0.281 ms | 0.861 ms |
Complete DIT\x01 Tag Registry
Classical ML Core & Linear (1–6, 38–42, 49–55)
| Tag | Class | Tag | Class | Tag | Class |
|---|---|---|---|---|---|
1 | LinearRegression | 38 | LogisticRegression | 50 | QuantileRegressor |
2 | DecisionTreeClassifier | 39 | Lasso | 51 | PoissonRegressor |
3 | DecisionTreeRegressor | 40 | ElasticNet | 52 | GammaRegressor |
4 | Ridge | 41 | SGDClassifier | 53 | TweedieRegressor |
5 | RidgeClassifier | 42 | SGDRegressor | 54 | LinearSVC |
6 | RidgeCV | 49 | HuberRegressor | 55 | LinearSVR |
Preprocessing, Imputation, Feature Extraction & Compose (7–37)
| Tag | Class | Tag | Class | Tag | Class |
|---|---|---|---|---|---|
7 | StandardScaler | 18 | SplineTransformer | 29 | FeatureHasher |
8 | MinMaxScaler | 19 | OneHotEncoder | 30 | CountVectorizer |
9 | MaxAbsScaler | 20 | OrdinalEncoder | 31 | TfidfTransformer |
10 | RobustScaler | 21 | LabelEncoder | 32 | TfidfVectorizer |
11 | Normalizer | 22 | LabelBinarizer | 33 | HashingVectorizer |
12 | Binarizer | 23 | MultiLabelBinarizer | 34 | IterativeImputer |
13 | KernelCenterer | 24 | TargetEncoder | 35 | FunctionTransformer |
14 | PolynomialFeatures | 25 | SimpleImputer | 36 | ColumnTransformer |
15 | KBinsDiscretizer | 26 | MissingIndicator | 37 | TransformedTargetRegressor |
16 | PowerTransformer | 27 | KNNImputer | ||
17 | QuantileTransformer | 28 | DictVectorizer |
Decomposition, Clustering, Neighbors, Naive Bayes, Ensembles, Kernels & Selection (43–48, 56–98)
| Tag | Class | Tag | Class | Tag | Class |
|---|---|---|---|---|---|
43 | PCA | 64 | GaussianMixture | 82 | MLPRegressor |
44 | TruncatedSVD | 65 | HistGradientBoostingClassifier | 83 | GaussianProcessRegressor |
45 | LinearDiscriminantAnalysis | 66 | HistGradientBoostingRegressor | 84 | GaussianProcessClassifier |
46 | QuadraticDiscriminantAnalysis | 67 | RandomForestClassifier | 85 | DBSCAN |
47 | KMeans | 68 | RandomForestRegressor | 86 | OPTICS |
48 | MiniBatchKMeans | 69 | ExtraTreesClassifier | 87 | SpectralClustering |
56 | KNeighborsClassifier | 70 | ExtraTreesRegressor | 88 | AgglomerativeClustering |
57 | KNeighborsRegressor | 71 | GradientBoostingClassifier | 89 | LocalOutlierFactor |
58 | RadiusNeighborsClassifier | 72 | GradientBoostingRegressor | 90 | NMF |
59 | RadiusNeighborsRegressor | 73 | AdaBoostClassifier | 91 | CCA |
60 | GaussianNB | 74 | AdaBoostRegressor | 92 | PLSRegression |
61 | MultinomialNB | 75 | IsolationForest | 93 | TSNE |
62 | BernoulliNB | 76 | SVC | 94 | MDS |
63 | ComplementNB | 77 | SVR | 95 | RBFSampler |
78 | OneClassSVM | 96 | VarianceThreshold | ||
79 | KernelRidge | 97 | SelectKBest | ||
80 | KernelPCA | 98 | SelectPercentile | ||
81 | MLPClassifier |
Deep Learning (ochreml.nn, 100–102)
| Tag | Class | Description |
|---|---|---|
100 | ochreml.nn.Sequential | Sequential neural network architecture & weights |
101 | ochreml.nn.CausalLM | Autoregressive Transformer / Causal Language Model |
102 | ochreml.nn.LoRAAdapterState | Low-Rank Adaptation (W + B * A) adapter weights |