Repository navigation
[Wheel] Keep integer dtype for typed_ragged rows when a row is an empty list - #4611
Conversation
|
Overall, the implementation looks sound: filtering empty Python Suggestion (non-blocking): Please add a regression case for The PR currently conflicts with |
…ty list NumPy gives an empty Python list a float64 dtype. Codec selection and typed_ragged encoding promoted that dtype together with the other rows, so a single [] row turned every integer row of a non_tensor_batch field into float64: [[1, 2], [], [2**53 + 1]] round-tripped as [[1.0, 2.0], [], [9007199254740992.0]]. Ignore empty list/tuple rows when inferring the common row dtype, and fall back to all rows only when every row is empty. ndarray rows keep their explicit dtype even when empty. Tests cover the int round trip, the _choose_leaf_codec decision for int and bool rows with an empty row, and a [[True, False], []] round trip that keeps the msgpack_ragged codec and bool values.
6eae0c2 to
d0f37bd
Compare
|
Thanks for the review. I rebased onto current main, so the change now lives in I added two tests for the codec-selection branch:
With only the |
…20261021 * upstream/main: (507 commits) [Reshard] Plan Store KV reuse across TP, PP and host layouts (kvcache-ai#4762) [Store] Walk tenants through shard-backed cursors and build the removes on them (kvcache-ai#4796) [Store-RS][Bugfix] Match TENT Request Layout to the C ABI (kvcache-ai#4732) [TransferEngine] Recover auto GID after data-path retry exhaustion (kvcache-ai#4290) [Store] Add the namespace layer over the object route (kvcache-ai#4721) [Store] Fix silent loss of offload keys deferred to the ungrouped pool (kvcache-ai#3006) (kvcache-ai#3009) [Store] Remove redundant alignment headroom from DFS shard allocation (kvcache-ai#4753) [CI/Build] Gate ROCm hardware tests and bound nightly Docker builds (kvcache-ai#4750) [Bugfix][Store] Fix double-counting of segment OpLog metrics in OpLogApplier (kvcache-ai#4771) [Store] Skip hot-cache writeback for device-resident read destinations (kvcache-ai#4764) [Reshard] Add bounded in-flight execution for weight transfers (kvcache-ai#4628) [Store] Avoid racing with detached hot-cache fills during key scans (kvcache-ai#4334) [Store] HA: drain the master on SIGTERM/SIGINT before exit (part 1 of kvcache-ai#4710) (kvcache-ai#4745) TENT: report a notification the receiver could not take (kvcache-ai#4754) [Store] Reach object metadata through a per-key accessor contract (kvcache-ai#4717) [Store][Bugfix] Fix DFS sync client test retry failure (kvcache-ai#4781) [Wheel] Keep integer dtype for typed_ragged rows when a row is an empty list (kvcache-ai#4611) [Doc] Sync README news onto the docs homepage (kvcache-ai#4767) [CI] remove stale Torch version binding after PG JIT (kvcache-ai#4760) [TransferEngine] Add buffer-protocol and page-gathered batch transfer APIs (kvcache-ai#4763) ...
…-ranges-20261021 * upstream/main: (394 commits) [Reshard] Plan Store KV reuse across TP, PP and host layouts (kvcache-ai#4762) [Store] Walk tenants through shard-backed cursors and build the removes on them (kvcache-ai#4796) [Store-RS][Bugfix] Match TENT Request Layout to the C ABI (kvcache-ai#4732) [TransferEngine] Recover auto GID after data-path retry exhaustion (kvcache-ai#4290) [Store] Add the namespace layer over the object route (kvcache-ai#4721) [Store] Fix silent loss of offload keys deferred to the ungrouped pool (kvcache-ai#3006) (kvcache-ai#3009) [Store] Remove redundant alignment headroom from DFS shard allocation (kvcache-ai#4753) [CI/Build] Gate ROCm hardware tests and bound nightly Docker builds (kvcache-ai#4750) [Bugfix][Store] Fix double-counting of segment OpLog metrics in OpLogApplier (kvcache-ai#4771) [Store] Skip hot-cache writeback for device-resident read destinations (kvcache-ai#4764) [Reshard] Add bounded in-flight execution for weight transfers (kvcache-ai#4628) [Store] Avoid racing with detached hot-cache fills during key scans (kvcache-ai#4334) [Store] HA: drain the master on SIGTERM/SIGINT before exit (part 1 of kvcache-ai#4710) (kvcache-ai#4745) TENT: report a notification the receiver could not take (kvcache-ai#4754) [Store] Reach object metadata through a per-key accessor contract (kvcache-ai#4717) [Store][Bugfix] Fix DFS sync client test retry failure (kvcache-ai#4781) [Wheel] Keep integer dtype for typed_ragged rows when a row is an empty list (kvcache-ai#4611) [Doc] Sync README news onto the docs homepage (kvcache-ai#4767) [CI] remove stale Torch version binding after PG JIT (kvcache-ai#4760) [TransferEngine] Add buffer-protocol and page-gathered batch transfer APIs (kvcache-ai#4763) ...
Description
put_dataproto/get_dataprotochanged integer list fields ofnon_tensor_batchto float64 if any row was an empty list. Rows[[1, 2], [], [2**53 + 1]]came back as[[1.0, 2.0], [], [9007199254740992.0]]with codec dtypefloat64. Both the element type and values above 2**53 changed. Without the empty row, the same field round-trips as int64.Nonerows are already excluded from inference.Cause:
np.asarray([]).dtypeis float64._choose_leaf_codec, in its list/tuple branch, and_encode_typed_ragged_values, when nodtype_hintis given, both pass that dtype tonp.result_typealong with the real rows.Fix: a small helper,
_typed_ragged_row_dtypes, leaves empty list/tuple rows out of promotion. It uses all rows only when every row is empty, so the all-empty case behaves as before. Emptynp.ndarrayrows still count, because their dtype is explicit. Both inference sites use the helper.Behaviour after the change (main shown in brackets where it differs):
[[1, 2], [], [2**53 + 1]][[1, 2], [], [9007199254740993]][(1, 2), ()][[1, 2], []][[True, False], []][[True, False], []]viamsgpack_ragged, same as without the[]row[[1.0, 0.0], []])[[1.5], []][np.array([], int32), np.array([1], int32)][[], []]Overlap: rebased onto the relocated module from #3633 (
python/mooncake/structured_object_store.py, tests inpython/tests/store/). The Rust store copy added in #4254 (python/mooncake/store/rs/structured_object_store.py) has no typed_ragged inference, so nothing to port there. #4603 (integer map keys inmsgpack_raggeddecode, still open) touches a different function but adds its test near the same spot intest_structured_object_store.py, so the second of the two may have a trivial test-file conflict. I found no issue or PR that reports this bug.Module
mooncake-transfer-engine)mooncake-store)mooncake-conductor)mooncake-reshard)mooncake-ep)mooncake-pg)mooncake-integration)mooncake-p2p-store)mooncake-wheel)mooncake-common)mooncake-rl)Type of Change
How Has This Been Tested?
Tests in
python/tests/store/test_structured_object_store.py:test_dataproto_helper_int_list_rows_with_empty_row_keep_int_dtype:[[1, 2], [], [2**53 + 1]]round trip keeps int values and int64 dtype.test_choose_leaf_codec_ignores_empty_list_rows_for_dtype:_choose_leaf_codecpickstyped_raggedwith dtype int64 for int list/tuple rows with an empty row, andmsgpack_raggedfor[[True, False], []], the same as for[[True, False]].test_dataproto_helper_bool_list_rows_with_empty_row_keep_bool_values:[[True, False], []]round trip usesmsgpack_raggedand keeps bool values.Test commands:
Test results:
Run on top of main at 19e0ab2 (Python 3.12, numpy 2.5.4, msgpack 1.2.3, pytest 9.1.1). On macOS the native
mooncake._storeextension is not built, so I ran with a small localsitecustomizestub that only providesReplicateConfigfor the import; the tests above useInMemoryStore, and the*_with_real_storetests are deselected.[9007199254740992.0] != [9007199254740993],'float64' == 'int64','typed_ragged' == 'msgpack_ragged'); the two files give3 failed, 150 passed, 27 skipped._choose_leaf_codecchange reverted: all 3 new tests fail. The codec test fails on'float64' == 'int64'. The round trips fail too, because the decision's float64 dtype overrides the encoder's metadata, so int64 bytes decode as float64 ([5e-324, 1e-323] != [1, 2]) and the bool payload fails to decode (buffer size must be a multiple of element size).153 passed, 27 skipped(main:150 passed, 27 skipped). The skips are the same tests that skip on main.Checklist
./scripts/code_format.sh(no C/C++ changes)ruff check0.6.9,scripts/ci/check_changed_python_format.py origin/main,ruff format --checkandcodespell2.2.6 all pass on both files.AI Assistance Disclosure
AI assistance: this change was drafted with an AI coding assistant (Claude) and verified locally with the tests above. I reviewed every changed line and can answer for the change.