Repository navigation
Reuse typed Arrow anchor IDs during Kumo preparation - #349
Conversation
Change mapObserved issue: preparation converts already correctly typed anchor ID columns through Python scalar lists at two native boundaries. The requested optimization removes that repeated work while preserving accepted inputs and errors.
Smallest sufficient change: one helper and its two call sites. Verification: 272 focused tests passed, 2 Linux-only checks skipped; six complete-job pairs preserve fitted state, counts, loss, weights and predictions exactly. The stopping condition is removal of these typed-key conversions while retaining validation behavior; broader dtype conversion optimizations remain separate. |
|
Note
|
Victsm
left a comment
There was a problem hiding this comment.
The typed Arrow reuse preserves the strict fallback normalization and native NULL/unknown-ID checks. The 57 focused anchor-key/handoff tests passed. On rebase, retain #442’s int64 warehouse-key coercion alongside this helper.
…-anchor-keys # Conflicts: # packages/experimental/kumo-pytorch/src/kumo/pytorch/engines/parquet_anchors.py
Victsm
left a comment
There was a problem hiding this comment.
Re-reviewed the rebase and retained the strict Arrow-key reuse/normalization behavior. The added managed-scratch test migration and registration-import annotation are narrow CI repairs. Re-approved after focused anchor-key, native-handoff and type-resolution verification.
Summary
DiskGraph-backed anchor preparation currently converts already typed Arrow ID columns to Python scalars, validates each scalar, and rebuilds an Arrow array. This repeats in scalar-value materialization and native anchor binding.
Reuse an integer/string array when its Arrow type exactly matches the declared key type. A shared private helper keeps the existing normalization path for every other input. There is no API change, new cache, or concurrency. Integer bounds, rejected coercions, null handling and unknown-entity checks retain their existing behavior.
Performance
Six sequential, counterbalanced comparisons against main
08577147e832585cc6e6094188ecb81f7bf904ae:All six whole-job pairs improved; individual reductions were 3.6–7.1%. Phase medians are calculated independently. Fitted-state fingerprints, sample/batch counts, mean training loss, final weights and predictions matched exactly in every pair.
The job builds a fresh index, materializes all anchors and fits input encoders, constructs the model/Adam optimizer, saves the Kumo artifact, trains one full epoch, rematerializes the inference task using the fitted state, runs the full test split, and closes resources. The timer includes preparation and fitting; it excludes Python startup, fixture generation and post-run output hashing.
Environment: macOS ARM64; Python 3.12.14, PyTorch 2.13.0, PyArrow 24.0.0, NumPy 2.5.4, DiskGraph 0.2.0 built from the same main commit. Native and PyTorch intra/inter-op thread settings are 1. The source is the existing
e2e.datasets.hmM fixture, generator version 2, seed 0: 50,000 customers, 5,000 articles, 1,246,040 transactions, 700,000 anchors; 400,000 train and 200,000 test examples. The consumer ise2e.flows.hm_gnn.PurchaseGNN, width 64, batch size 512, seed 0, Adam 1e-3.AnchorTablescalar entity features and aggregate targetsThis is CPU synthetic-fixture evidence with a warm filesystem cache and no exclusive CPU allocation. It is not an Arena-model, GPU or full-data result, and does not establish a 5% improvement for long, model-dominated training jobs. The measured improvement is below the later 10% target; this smaller, independently reviewable optimization is intentionally being proposed separately.
Testing Done
From
packages/experimental/kumo-pytorch, using the selected compatible native runtime andPYTHONPATH=src:272 passed, 0 failed, 2 skipped (Linux
/procmapping accounting). New coverage includes signed/unsigned bounds, nulls, duplicates, Unicode, mismatched integer widths, rejected bool/float/string coercions, overflow, large-string fallback and the existing native null-key exception. Ruff andgit diff --checkpass.Change map
File-by-file change map
Checklist