Skip to content

Use shared tensor mappers for runtime targets - #582

Open
haoweiyu-kumo wants to merge 7 commits into
mainfrom
skip_arrow_pylist_conversion_target
Open

haoweiyu-kumo wants to merge 7 commits into
mainfrom
skip_arrow_pylist_conversion_target

Conversation

@haoweiyu-kumo

@haoweiyu-kumo haoweiyu-kumo commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Use the shared tensor mappers for supervised runtime targets, removing the adapter's duplicated conversion helpers. Link prediction keeps flat int64 IDs, forecasting keeps its separate supervision path, and unlabeled batches omit .y.

Normalize categorical target vocabularies from string-valued statistics to the physical target dtype when constructing the encoder. Save that dtype as compact JSON in version 2 encoder metadata so unlabeled prediction restores the same class types. Resumed training can populate missing metadata from the labeled seed schema. DiskGraph statistics publication is unchanged.

Target mappers reject unknown labels and omit null or empty multilabel entries. Feature mappers retain their existing permissive behavior. Preserve binary class ordering for existing checkpoint weights. Legacy model metadata without a recorded dtype continues to emit string classes.

Change map

File-by-file changes, rationale, and verification.

Testing Done

  • 361 focused core tests and 85 adapter tests passed locally.
  • Five public integer-target fit/predict/reload cases passed, covering static, temporal, and custom training tables.
  • Candidate GitHub runs passed core and Engine package tests, CPU lifecycle, GPU model, PyArrow compatibility, flake8, and pyright checks.
  • Follow-up corrects the integer-target test's import ordering and refreshes PR metadata; no workflow changes.

Checklist

  • Listed target mapping and saved-metadata compatibility behavior above.
  • Added unit tests and public API regression coverage.
  • Reviewed examples and documentation; no changes needed.

@haoweiyu-kumo

haoweiyu-kumo commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator Author

Change map

File Function / scope What changed Why
packages/kumo-core/src/kumo_core/automl/auto_trainer.py _resolve_encoders Record the physical target dtype before saving new or resumed encoder configurations. Retain numeric vocabulary types when prediction tables have no labels.
packages/kumo-core/src/kumo_core/diskgraph/runtime_adapter.py _attach_seed_table and removed target helpers Delegate supervised targets to tensor_mapper; preserve direct int64 link IDs and separate forecasting supervision. Remove duplicated Arrow-to-Python target conversion.
packages/kumo-core/src/kumo_core/encoders/config.py TargetEncoderConfig and EncodersConfig Persist compact Arrow type aliases and tagged arrays with metadata version 2; recognize unversioned metadata. Reconstruct target types without depending on prediction labels.
packages/kumo-core/src/kumo_core/encoders/target/base.py from_encoder and _typed_target_counts Normalize vocabulary labels to the target dtype, enable strict target lookup, and preserve binary orientation and multilabel shape. Support string statistics and cached vocabularies, including large unsigned integers, without changing feature vocabularies or checkpoint class ordering.
packages/kumo-core/src/kumo_core/encoders/tensor_mapper.py CategoricalTensorMapper and MultiCategoricalTensorMapper Add opt-in strict unknown-label validation and omit null or empty multilabel entries in strict mode. Reject invalid target labels instead of indexing the last class; retain permissive feature mapping.
packages/kumo-core/src/kumo_core/task_dataset.py DiskgraphTaskManifest.target_dtype Read the physical target type from the materialized seed schema. Resolve training target types independently of string-valued statistics.
packages/kumo-core/src/kumo_core/train/trainer.py target_dtype, target_encoder, and save_encoders Restore the persisted dtype, default legacy metadata to string labels, and save metadata version 2. Keep unlabeled prediction consistent with training and explicitly preserve legacy string output.
packages/kumo-core/tests/encoders/test_strict_target_mapping.py Strict mapper tests Cover unknown labels, nulls, empty entries, and permissive feature behavior. Prevent silent last-class selection and feature regressions.
packages/kumo-core/tests/encoders/test_target_dtype_metadata.py Metadata and trainer round-trip tests Cover compact type serialization, legacy metadata, training persistence, and unlabeled prediction. Verify saved artifacts preserve target types and legacy fallback.
packages/kumo-core/tests/encoders/test_target_vocabulary_dtype.py Vocabulary normalization tests Cover cached and native labels, unsigned boundaries, safe casts, binary orientation, and multilabel types. Verify valid numeric vocabularies remain compatible without unsafe coercion.
packages/kumo-core/tests/test_runtime_adapter_targets.py Seed-table routing tests Cover mapper delegation, link-ID precision, forecasting omission, absent targets, and missing encoders. Protect each target-routing branch.
packages/kumo-engine/test/test_integer_categorical_targets.py Public fit, predict, and reload tests Exercise static, temporal, and custom integer categorical targets through the public Engine API. Verify numeric classes survive training and unlabeled prediction after reload; use default test discovery.
test/data/generic/test_diskgraph_runtime_adapter.py Adapter fixtures and target expectations Supply explicit encoders and assert mapper-defined target shapes. Exercise the shared mapper contract through the runtime adapter.
test/train/datamodule/test_diskgraph_lightning_data.py Supervised datamodule fixtures Supply numerical target encoders. Match production construction for labeled batches.
test/train/test_diskgraph_nested_trainer.py test_eval_df_uses_adapter_normalized_seed_time Supply the regression target encoder helper. Retain timestamp regression coverage under the explicit encoder requirement.

Request: replace custom runtime target conversion with the shared Arrow tensor mappers. Existing statistics store categorical labels as strings, so direct delegation also needs vocabulary normalization to avoid rejecting valid numeric targets. Unknown target labels must continue to raise rather than select the last class.

Smallest sufficient change: normalize vocabulary labels at target encoder construction; persist their physical dtype in version 2 encoder metadata; enable strict mapping only for targets. Keep DiskGraph statistics publication unchanged. Legacy metadata without a target dtype produces string classes; resumed training records the dtype from its labeled seed schema.

Verification: 361 focused core tests and 85 adapter tests passed locally. All five public integer-target fit/predict/reload cases passed. The candidate commit's GitHub package, CPU lifecycle, GPU model, PyArrow compatibility, flake8, and pyright checks passed. The follow-up only corrects import ordering and refreshes this map; no workflow changes are needed.

Stopping condition: the adapter uses shared target mappers, cached numeric vocabularies and unlabeled prediction are covered, unknown labels raise, and the existing CI checks pass. Optional changes to manually constructed internal trainers or unsupported separator configurations are outside this fix.

@haoweiyu-kumo
haoweiyu-kumo temporarily deployed to gha-kumo-workflow-tests December 1, 2026 23:24 — with GitHub Actions Inactive
@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Explain Change →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • Resume reviews
  • Trigger review

Note

.coderabbit.yaml has unrecognized properties

CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.

Parsing warnings: 1

Validation error: Unrecognized key: "tone_instructions" at "reviews"
Configuration instructions

  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Walkthrough

The changes add Arrow target-dtype metadata and use physical target types when restoring categorical vocabularies. They add strict target-mapping modes. The runtime adapter sends supervised targets through a target encoder and attaches link-prediction targets as flattened long tensors. Tests cover metadata compatibility, target mapping, runtime conversion, and integer categorical targets through training, prediction, and model reload.

Sequence Diagram(s)

sequenceDiagram
  participant RuntimeAdapter
  participant TargetEncoder
  participant TensorMapper
  RuntimeAdapter->>TargetEncoder: map supervised target
  TargetEncoder->>TensorMapper: map typed target values
Loading
Merge Risk: Moderate · up to ffc16

Integer categorical targets can fail during direct training, or when evaluating legacy checkpoints that have no saved target type. The target type is only saved on the AutoTrainer path, and the fallback treats labels as strings. Resolve or explicitly accept this gap before merging.

Security architecture risk: Moderate · up to ffc16

Factory-built target encoders reject unknown labels, but a caller-supplied permissive multilabel encoder can silently turn an invalid label into supervision for the last class. Some warm starts can also stop before saving encoder metadata, even when the checkpoint is readable. The demonstrated effects are on the affected training run and its model; broader exposure was not established.

Retained concerns

  • Minor · security · observed: The adapter now trusts a supplied mapper to return valid supervision indices. With a directly constructed permissive multilabel mapper and a nonempty vocabulary, an unknown label or empty list row can yield minus one and set the last class in the multi-hot target. The merge-base adapter rejected unknown labels and left empty rows empty. Factory-built strict encoders reject unknown labels and omit empty entries, so this does not affect the default path.
  • Minor · reliability · observed: AutoTrainer could previously copy readable checkpoint encoder metadata without consulting the seed schema at that step. A bundle-backed warm start with no saved target dtype now stops before saving destination metadata if the first seed part cannot be read or its type cannot be recorded. A saved dtype bypasses the new read. Recovery requires restoring the expected bundle and seed part, or supplying compatible encoder metadata with the correct dtype.
  • Trivial · reliability · observed: The PR documents the switch to regex splitting. The remaining exposure is that an existing literal multicharacter separator is now interpreted as a Python regex without a separate opt-in. It can change the labels presented to validation or stop the batch if it cannot compile. Matching also adds input-dependent work before validation; untrusted control of separator statistics and impact beyond the job were not established.
  • Trivial · reliability · inferred: Accepting unversioned metadata preserves file readability, not target compatibility. When dtype backfill does not run or finds no target field, Trainer defaults the vocabulary to strings. An integer categorical batch can then fail strict lookup even when the fitted vocabulary contains the corresponding labels. The merge-base adapter could match those labels through its string fallback. This is distinct from the new schema-read failure: metadata resolution can succeed and training can still stop at batch conversion.

View findings in the submitted review

Security review details

Security Blast Radius

  • inferred — The supervision integrity issue is scoped to a run that both accepts label input and uses a permissive multilabel encoder. It can change that run's training targets and thus its model. The evidence does not establish that a label supplier can choose the encoder or affect other tenants' runs.

Security Findings and Attack Paths

  • observed — The changed agreement between the adapter and the supplied mapper allows a permissive mapper's missing-label sentinel to reach a model-side write as a valid negative index. Strict factory mapping rejects unknown entries before that write and omits empty rows instead of emitting placeholders.

Trust Boundaries and Controls

  • observed — The new schema read uses manifest-supplied stage paths under the training process's existing file permissions. The read site does not check path containment. This is an additional use of the existing bundle input; deployed manifest provenance, upstream containment, and any expansion of effective access remain unestablished.

Dependencies

  • observed — Backfill relies on the current bundle's first seed part, not on a stored link between that part and the checkpoint vocabulary. The backfill step does not compare the bundle target with the checkpoint target, and skips the read entirely when a saved dtype exists. Whether operators can pair mismatched artifacts is unresolved.

Data and control flow

  • observed — The seed schema supplies the type used to rebuild the fitted vocabulary. The mapper then translates batch labels to compact IDs, which the model's multilabel encoder uses as column indices.

Resilience and Maintainability Implications

  • observed — A schema-read or dtype-recording failure happens before AutoTrainer saves destination metadata or caches the resolved encoders. An existing destination file can therefore remain after a failed attempt; its presence does not acknowledge the new restore. Retrying a checkpoint-backed attempt reloads the checkpoint metadata and repeats backfill if the dtype is still absent. Once writing starts, publication still uses the merge base's direct JSON writer, which does not add atomic replacement or coordinate concurrent writers.

Hardening Proposals

  • proposed — Enforce valid class indices at the supervision boundary regardless of mapper configuration, without changing permissive feature mapping.

Rollout and rollback

  • observed — For bundle-backed warm starts without a saved dtype, the seed bundle can now block encoder resolution even when the checkpoint owner has supplied readable metadata. The operator must restore the expected seed artifact or provide correctly typed metadata before retrying. Compatibility of version 2 output with older binaries was not validated.
Pre-merge checks: Passed 2 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Change Map Design Review Warning (previously flagged, unaddressed) Details from the previous assessment are unavailable.
Passed Passed checks: 2 passed

Check name Status Explanation
Pr Size Passed PR size check: PASS. The provider-reported primary PR is NVIDIA/kumo-engine #582 (head skip_arrow_pylist_conversion_target, base main). I compared the local HEAD (62ac7ed, the head commit described in…
Public Resource Access Passed The check covers only external resource references (URLs, repository locations, package source locations) whose text this PR adds or modifies. I diffed the PR head against its merge base with origin/m…
Full details: Pr Size

Explanation

PR size check: PASS. The provider-reported primary PR is NVIDIA/kumo-engine #582 (head skip_arrow_pylist_conversion_target, base main). I compared the local HEAD (62ac7ed, the head commit described in the PR follow-up) against the merge-base with origin/main (868c074). The committed diff touches 39 files, both with and without rename detection. That is at or below the limit of 40, so the check does not fail. Breakdown: 3 added test files, 36 modified files. The raw summary lists only 15 files, so it was incomplete. The file count comes from git, not the summary. Line counts were ignored, as the check requires. The 39-file count is close to the threshold, so further additions to this PR could push it over 40.

Full details: Public Resource Access

Explanation

The check covers only external resource references (URLs, repository locations, package source locations) whose text this PR adds or modifies. I diffed the PR head against its merge base with origin/main (868c074…, 39 changed files) and searched every added line for http/https, www., git+, git@, ssh://, index-url, find-links, registry, wheel/tarball names, raw.githubusercontent, and common host suffixes. No added line contains an external reference. The only URL-bearing line in the diff is a removed comment (# issue https://github.com/kumo-ai/kumo/issues/5841), which the check excludes. The PR description links to a PR comment, but that text is not a repository change and is not needed to understand, build, or test the changed code. The check passes because the PR adds or changes no external resource reference.

Latest assessment: Change Map Design Review

Latest assessment: The latest assessment was inconclusive; the previous failure remains unresolved.

Latest explanation: The check reviews the PR conversation comment that begins with <!-- kumo-pr-change-map -->. That comment is not in the supplied context. The review comments section lists only three CodeRabbit inline threads. Searches of the checkout found the marker only in docs/development/review.md, which describes the required format. The git refs hold no PR comment text. The PR change map therefore cannot be assessed against the four design criteria: necessity, abstraction layer, preserved behavior, and verification or stopping condition. The standing FAIL from the prior run cannot be disposed of, because its explanation is unavailable and the map it judged is not accessible. Code evidence gathered while checking the linked review threads: - packages/kumo-core/src/kumo_core/train/trainer.py:1067 returns (target.arrow_dtype or pa.string()) for any target without recorded dtype metadata. The direct training path passes that type into TargetEncoder.from_encoder. packages/kumo-core/src/kumo_core/encoders/target/base.py:92 and :112 build strict categorical and multi-categorical mappers. A raw int64 label such as 2 can fail strict lookup against the string vocabulary entry "2". This matches the unresolved CodeRabbit concern about legacy integer categorical targets. The PR description states only that legacy metadata "continues to emit string classes" for prediction. It does not mention this training-path behavior change, so the map may omit material behavior. - The CodeRabbit thread on UInt64 categories at or above 2^63 (packages/diskgraph/diskgraph-train-table/src/ttgen_stats.rs:1229) is still unconfirmed. It bears on the map's claim that DiskGraph statistics publication is unchanged. I did not verify it, because the Rust path is outside the scope of this check's Python evidence. These findings are code evidence only. They do not establish a defect in the change-map comment itself, so they are not used to fail the check.

Latest resolution: To complete this check, provide the text of the PR conversation comment that starts with <!-- kumo-pr-change-map -->, or make it reachable from the review environment. Then re-run the check. Also address these points in that comment or in the code: 1. State the training-path behavior for legacy integer categorical targets. Either restore label-type handling for targets without dtype metadata, or document the strict-mapping failure and its migration path. 2. Confirm the UInt64 category path in ttgen_stats.rs (line 1229). The map should either state that DiskGraph statistics publication is unchanged for unsigned values at or above 2^63, or the path should be fixed. 3. Confirm that the map gives the verification and stopping condition for each design change.

Finishing Touches

Fix failing CI checks

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🏛️ Architecture findings (1)

Advisory architecture findings (1)

  • Trivial — A failed direct label lookup can trigger a fixed-width string allocation across the entire batch. Its size scales with the number of labels times the longest label, and the multilabel path includes already matched rows. The base did not pad all labels to a common width and scoped multilabel fallback to one row at a time. The new allocation can interrupt the process handling the batch before label validation completes; wider impact is not established.

💬 Code review

Note

Quiet mode is enabled, so only the most important comments were posted inline. Other review comments are grouped below.

Other comments: 1

packages/kumo-core/src/kumo_core/diskgraph/runtime_adapter.py: 1

1143-1151: Minor · Data Integrity & Integration · Quick win

Reject null child elements in dense list targets.

The new path rejects null rows (values.null_count). It does not check null elements inside a row. For example, [[1.0, None], [3.0, 4.0]] has no null rows, and every row has width 2. The code flattens it, and _values_to_tensor calls to_numpy(zero_copy_only=False). That call converts the null to NaN. The float32 tensor then carries a NaN label.

The old code passed to_pylist() output to torch.tensor, which raised an error for None. The new code silently changes that failure into corrupt training or evaluation targets. The new tests cover null rows but not null elements. Add a check on the flattened values:

Proposed fix

-        return _values_to_tensor(pc.list_flatten(values), dtype=torch.float32).reshape(
-            len(values), width
-        )
+        flat = pc.list_flatten(values)
+        if flat.null_count:
+            raise ValueError("Dense targets must not contain null elements")
+        return _values_to_tensor(flat, dtype=torch.float32).reshape(
+            len(values), width
+        )

Also add a test with a null element. Based on learnings, a code path that casts a nullable array needs a test with at least one null element.

Source: Learnings

Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 734f206 and 01e47bc.

Files selected for processing: 2

  • packages/kumo-core/src/kumo_core/diskgraph/runtime_adapter.py
  • packages/kumo-core/tests/test_runtime_adapter_targets.py

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 10 remain after this review.

@haoweiyu-kumo
haoweiyu-kumo temporarily deployed to gha-kumo-workflow-tests December 2, 2026 06:43 — with GitHub Actions Inactive
@haoweiyu-kumo haoweiyu-kumo changed the title Avoid Python lists when converting Arrow targets to tensors Reuse target tensor mappers in the runtime adapter Dec 2, 2026
@haoweiyu-kumo haoweiyu-kumo changed the title Reuse target tensor mappers in the runtime adapter Use shared tensor mappers for runtime targets Dec 2, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments

Minor 2
  1. DiskGraph no longer distinguishes an unmapped supervised label from a missing label at the adapter boundary. Labels that previously resolved through coercion can now become -1, and labels that previously stopped conversion can leave the adapter in y as -1. This moves rejection or omission downstream, where the result depends on the task consumer.
  2. DiskGraph batch conversion can now set the multilabel mapper&`#39`;s decode format before conversion succeeds. An all-null first nonempty batch sets list mode even for a string target. Subsequent valid batches do not correct it, so prediction decoding on the same mapper can return arrays of labels instead of separator-joined strings. A failure after the assignment can leave the same state without publishing a converted target.
Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 01e47bc and 920099e.

Files selected for processing: 5

  • packages/kumo-core/src/kumo_core/diskgraph/runtime_adapter.py
  • packages/kumo-core/tests/test_runtime_adapter_targets.py
  • test/data/generic/test_diskgraph_runtime_adapter.py
  • test/train/datamodule/test_diskgraph_lightning_data.py
  • test/train/test_diskgraph_nested_trainer.py

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.

@Vedaant-J Vedaant-J left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this breaks training on integer categorical target columns

@Vedaant-J

Copy link
Copy Markdown
Contributor

specifically, the code deleted in runtime adapter had a fallback for the target col and diskgraph col stats, and this PR treats target col as another feature column. However, the speedup is useful so we probably need to fix a deeper root cause

@Vedaant-J

Copy link
Copy Markdown
Contributor

The vocabulary keys which are from category col stats are always strings: DiskGraph's training-table stats publish categories "by their spelling" (ttgen_executor.rs:2463, 2485). But if your target column is an integer,
the batch values arrive as int64.

vocabulary: {"0": 0, "1": 1, "2": 2} (string keys)
batch target: [2, 0, 1] (int64)

main: lookup 2 → miss → retry "2" → 2 → y = [2, 0, 1]
#582: lookup 2 → miss → -1 → y = [-1, -1, -1]
→ loss: IndexError: Target -1 is out of bounds

The agent reproduced this through the public API:

  • PREDICT FIRST(orders.cat, …) on an integer column: crashes.
  • PREDICT users.tier on an integer column: crashes.
  • Custom training tables with integer binary or multiclass labels: crash.

So either diskgraph when publishing col stats does not cast to string (this requires some changes due to json type semantics) or we introduce a special function to read back vocab jsons keys in original type.

@Vedaant-J

Copy link
Copy Markdown
Contributor

the other problem is unknown multilabel labels silently becoming the wrong label

For multilabel, encode_tensor() builds the 0/1 row by using each ID as an index. In Python and PyTorch, index -1 means the last position.

vocabulary: {"c1": 0, "c2": 1, "c3": 2, "c4": 3}
row: "c1|c5" ("c5" is new, not in the vocabulary)

main: ValueError: ... not present in target encoder mapping: ['c5']
#582: ids [0, -1] → multi-hot [1, 0, 0, 1] → trained as "c1 and c4"

The row is now trained as c1 plus c4, the last and least frequent class, with no error.

A related symptom: custom labels with spaces, like "c3 | c4", fail clearly on main. On the PR they surface later as a misleading "val_ap_macro is NaN, increase max_val_steps" after almost a full loop of training.

@haoweiyu-kumo
haoweiyu-kumo temporarily deployed to gha-kumo-workflow-tests December 3, 2026 19:50 — with GitHub Actions Inactive

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments

Major 1
  1. UInt64 categories at or above 2^63 can abort training-table generation.
Minor 2
  1. Initialize the decode format from typed list input.
    packages/kumo-core/src/kumo_core/encoders/tensor_mapper.py, lines 516 · 🩺 Stability & Availability · ⚡ Quick win
    If the first strict batch is pa.array([None], type=pa.list_(pa.int64())), has_values is false and _is_string_dtype remains None. With vocabulary [[42, 1]] and sep="|", encoder.decode(torch.tensor([[1.0]])) then reaches self.sep.join with integer label 42 and raises TypeError. The same typed-null batch previously set _is_string_dtype=False, which selected list reconstruction. (raw.githubusercontent.com)
    Initialize the list format when the Arrow type establishes it, even when every row is null. Continue deferring format selection for untyped pa.nulls() input.
  2. The merge-base adapter rejected unknown multilabel values when an encoder was supplied, regardless of its mapper settings. The reviewed adapter accepts a directly constructed permissive target encoder and forwards its output without checking the indices. With a nonempty vocabulary, an unknown label mapped to -1 can set the final class in the downstream multi-hot target instead of rejecting the batch. Factory-built encoders reject the invalid label, so this is not the default trainer behavior.
Trivial 1
  1. DiskGraph now rejects category keys that cannot be represented as their declared JSON type, including non-finite floating-point category keys that the merge base could serialize as strings. That rejection happens after the generation pass writes Parquet files. Generated-table staging can remain on disk until retry, and custom generation does not remove a directory it did not create. This is a failure-containment issue, not evidence that normal ingest publishes a failed attempt.

Note

Quiet mode is enabled, so only the most important comments were posted inline. Other review comments are grouped below.

Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 920099e and 41bf0be.

Files selected for processing: 8

  • packages/diskgraph/diskgraph-train-table/src/custom_tt_chunk_processor.rs
  • packages/diskgraph/diskgraph-train-table/src/ttgen_executor.rs
  • packages/diskgraph/diskgraph-train-table/src/ttgen_stats.rs
  • packages/diskgraph/diskgraph-train-table/tests/custom_tt_integration.rs
  • packages/diskgraph/diskgraph-train-table/tests/ttgen_integration.rs
  • packages/kumo-core/src/kumo_core/encoders/target/base.py
  • packages/kumo-core/src/kumo_core/encoders/tensor_mapper.py
  • packages/kumo-core/tests/encoders/test_strict_target_mapping.py

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.

key.parse::<i64>().map(|v| json!(v)).map_err(|_| invalid())
}
Some(DataType::UInt8 | DataType::UInt16 | DataType::UInt32 | DataType::UInt64) => {
key.parse::<u64>().map(|v| json!(v)).map_err(|_| invalid())

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Major · Data Integrity & Integration · Heavy lift

UInt64 categories at or above 2^63 can abort training-table generation.

For a UInt64 categorical target, the reader casts each value to i64. A value at or above 2^63 becomes a negative Value::Int. Its category key then starts with -. typed_target_category parses UInt64 keys as u64, so that key fails with SchemaError. The error propagates through finalize, so generation stops for an otherwise valid target. Before this change, the same key was published as the string "-1" and generation completed with a wrong label. This change turns that silent mislabel into a hard failure.

The unsigned value must stay exact from the reader to the category key. For example, u64::MAX must publish as 18446744073709551615. The signed Value::Int cast in value_ref_to_value must not apply to unsigned targets. The existing unit test passes that decimal string directly to typed_target_category, so it does not cover this path.

@Vedaant-J

Copy link
Copy Markdown
Contributor

this is causing a breaking change where model trained with previous code will break when predicting with this code? maybe add a legacy fallback?

@Vedaant-J

Copy link
Copy Markdown
Contributor

add CI tests for integer categorical target columns

@haoweiyu-kumo
haoweiyu-kumo temporarily deployed to gha-kumo-workflow-tests December 3, 2026 23:19 — with GitHub Actions Inactive

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments

Major 2
  1. Use the requested dtype before inferring native integer labels.
  2. Legacy integer categorical targets fail on the direct training path.
Minor 2
  1. The merge-base adapter rejected unknown multilabel values even when the supplied encoder was permissive. The new adapter stores mapper output without checking the IDs. A directly constructed permissive mapper can emit minus one for an unknown value or an empty list row; with a nonempty vocabulary, the downstream multi-hot write treats that ID as the last class. Factory-built target encoders reject unknown labels and omit empty entries, so the default trainer path does not exhibit this behavior.
  2. AutoTrainer previously copied checkpoint encoder metadata without reading a seed schema at that step. On a bundle-backed warm start with no saved target dtype, it now reads the current bundle's first stage Parquet schema before saving the destination metadata. A missing or unreadable first-stage part stops encoder resolution even when the checkpoint and its encoder metadata are readable. The operator must restore the expected bundle or seed part before retrying this path. Encoders that already carry a dtype skip the read.
Trivial 1
  1. Delegation changes scalar multilabel target parsing from literal splitting to Python regular-expression execution for configured multicharacter separators. A separator that callers previously used as literal text can change tokenization or abort the batch if it is not valid regex. Regex matching also introduces input-dependent CPU cost before label validation. This is a changed training-job failure mode; control of separator statistics by an untrusted party and impact beyond the job were not established.
Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 41bf0be and 5d3a4ed.

Files selected for processing: 9

  • packages/kumo-core/src/kumo_core/automl/auto_trainer.py
  • packages/kumo-core/src/kumo_core/encoders/config.py
  • packages/kumo-core/src/kumo_core/encoders/target/base.py
  • packages/kumo-core/src/kumo_core/encoders/tensor_mapper.py
  • packages/kumo-core/src/kumo_core/task_dataset.py
  • packages/kumo-core/src/kumo_core/train/trainer.py
  • packages/kumo-core/tests/encoders/test_target_dtype_metadata.py
  • packages/kumo-core/tests/encoders/test_target_vocabulary_dtype.py
  • packages/kumo-engine/test/test_integer_categorical_targets.py

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.

@haoweiyu-kumo
haoweiyu-kumo temporarily deployed to gha-kumo-workflow-tests December 4, 2026 00:06 — with GitHub Actions Inactive
@haoweiyu-kumo

Copy link
Copy Markdown
Collaborator Author

@Vedaant-J Ok I added a more generalized fix: basically record the target column dtype, and when building the index, the code will parse the string into the target column's dtype to reflect the index more accurately:
e.g.
the stats is still
[
["2", 2], ["3", 3]
]
and because the target column dtype stats is int64, then the index will parse it into 2 instead of "2", this way we can support general type like timestamp and boolean.

In case of compat: the training should be fine because the code will now read training table target column's dtype, as for prediction: we won't find the dtype for a model trained with previous code, in those cases, we will not emit the original type of label but string. i.e. the prediction output will be "2" instead of 2. I think that's probably fine?

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments

Minor 2
  1. The adapter now trusts a supplied mapper to return valid supervision indices. With a directly constructed permissive multilabel mapper and a nonempty vocabulary, an unknown label or empty list row can yield minus one and set the last class in the multi-hot target. The merge-base adapter rejected unknown labels and left empty rows empty. Factory-built strict encoders reject unknown labels and omit empty entries, so this does not affect the default path.
  2. AutoTrainer could previously copy readable checkpoint encoder metadata without consulting the seed schema at that step. A bundle-backed warm start with no saved target dtype now stops before saving destination metadata if the first seed part cannot be read or its type cannot be recorded. A saved dtype bypasses the new read. Recovery requires restoring the expected bundle and seed part, or supplying compatible encoder metadata with the correct dtype.
Trivial 2
  1. The PR documents the switch to regex splitting. The remaining exposure is that an existing literal multicharacter separator is now interpreted as a Python regex without a separate opt-in. It can change the labels presented to validation or stop the batch if it cannot compile. Matching also adds input-dependent work before validation; untrusted control of separator statistics and impact beyond the job were not established.
  2. Accepting unversioned metadata preserves file readability, not target compatibility. When dtype backfill does not run or finds no target field, Trainer defaults the vocabulary to strings. An integer categorical batch can then fail strict lookup even when the fitted vocabulary contains the corresponding labels. The merge-base adapter could match those labels through its string fallback. This is distinct from the new schema-read failure: metadata resolution can succeed and training can still stop at batch conversion.
Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 5d3a4ed and ffc16cc.

Files selected for processing: 4

  • packages/kumo-core/src/kumo_core/encoders/config.py
  • packages/kumo-core/src/kumo_core/encoders/target/base.py
  • packages/kumo-core/tests/encoders/test_target_dtype_metadata.py
  • packages/kumo-core/tests/encoders/test_target_vocabulary_dtype.py

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 10 remain after this review.

@haoweiyu-kumo
haoweiyu-kumo temporarily deployed to gha-kumo-workflow-tests December 4, 2026 00:43 — with GitHub Actions Inactive

This branch was previously deployed

1 inactive deployment
gha-kumo-workflow-tests — 62ac7ed6 Deployed Dec 4, 2026 by haoweiyu-kumo via import #3634
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants