You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Use shared tensor mappers for runtime targets - #582
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.
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.
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.
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.
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"
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.
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.
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: 2 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Change Map Design Review
(previously flagged, unaddressed)
Details from the previous assessment are unavailable.
Passed checks: 2 passed
Check name
Status
Explanation
Pr Size
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
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
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.
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.
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
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
changed the title
Reuse target tensor mappers in the runtime adapter
Use shared tensor mappers for runtime targets
Dec 2, 2026
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments
2
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.
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.
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.
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
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.
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.
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.
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.
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.
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.
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.
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.
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.
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.
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.
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 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?
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments
2
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.
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.
2
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.
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.
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 10 remain after this review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Checklist