Repository navigation
Description
This is a tracking issue for adding a Widen encoding for integers and decimals, which stores logical values that can fit in a smaller bit width or precision in a smaller logical dtype.
- Adapted from Epic: Implement Narrow integer encoding #10020
Status
Integer and decimal Widen execute on the CPU and GPU (#10946, #11303). Its wire format (#11597) and the tightened DecimalByteParts v2 reader (#11596) have merged. Both formats are available in unstable (#11615). Preview and core promotion remain open. DecimalByteParts keeps integer Widen for its narrow MSP. Existing integer paths keep their current representations. Structural and dictionary changes (WD5), internal-child migration (WD6), and the integer Narrow scheme (WR3) are deferred.
Motivation
We have the concept of "narrowing" data in a few places.
- In the compressor, if we have a
Primitiveinteger array that does not contain very large values, we will call anarrow()method on the primitive array to shrink the logical dtype to fit the values. For example, if my values are all in[-128, 127], but the dtype isI64, then I can narrow this toI8. We use this with list offsets, for example. Note that this changes the dtype of the array. - Narrowing can also happen with explicit casts (which are fallible), but this also changes the dtype.
- In the canonical decimal encoding, there is currently implicit narrowing of the buffer when possible. This is arguably very wrong, see Tracking Issue: Fix Canonical Decimal #10701 for more details.
Ideally, we want a way to keep the logical type of these values while having a better physical encoding that narrows data internally. This is why we want a Widen encoding.
Design
The encoding is named after what decoding does: like FoR is an addition, Widen is a widening cast of its child (see #9156). The compressor scheme that builds it narrows the data, so it keeps the name Narrow.
The Widen encoding will have a single array child that has a narrower logical dtype. For integers, the child has the same signedness and a strictly smaller power-of-two bit width. For decimals, the child has a lower precision whose canonical width is strictly smaller, with the same scale. A positive scale sets a lower bound on that precision. The child always has the same nullability as the parent, and supplies its validity.
For example, a Widen array of I64 can hold an I8 child (if it fits). Or, a Widen array of Decimal(18, 2) (with a 64-bit buffer) can hold a child of Decimal(9, 2) (with a 32-bit buffer).
We can constrain the child of the Widen array such that it must actually shrink the amount of data we need to store. This is only relevant for Decimal: having a Widen(Decimal(17, 2)) with dtype Decimal(18, 2) is completely pointless because it doesn't actually save any space. This is something we might be able to relax in the future, but it seems like a reasonable constraint for now.
Note that the compressor narrowing an internal child does not need to change. This is because list offsets, dictionary codes, run-end ends, patch indices, and other internal children have dtypes that their parent encoding chooses, so a narrow integer dtype there is "correct" by default, and these children technically do not need a Widen. #11459 fixes the logical dtype of the DecimalByteParts most significant part (MSP) from the precision, so narrower MSP storage does need an integer Widen.
Compute
A consequence of making narrowing a physical concern rather than a logical one is that we will need to forward lots of compute into the Widen array's child.
Kernels run on the child at the narrow width and widen only when the result needs it. Any operation without a kernel falls back to canonicalization, which widens the child to the logical dtype.
Compute behavior and remaining work
| Operation | Behavior on Widen |
|---|---|
slice, filter, take, mask, fill_null, zip |
Run on the child. |
compare, between |
Run on the child. A constant outside the range of the child dtype gives the result without reading the values. |
| Arithmetic | Runs at the smallest width that holds both inputs and the result interval, taken from the non-null bounds. Otherwise it runs at the logical width with checked kernels. |
min, max, sum and other aggregates |
Must preserve the canonical array's results and overflow behavior, including when combining running partials. Ordered aggregates can widen child partials. Decimal Sum pushdown in #11004 uses the logical sum dtype only for the legacy Stat::Sum path. SumV2 and sums without skip_nans keep the fallback. |
cast |
Passes to the child with the same target dtype, since a Widen holds exactly the values of its child. |
| Generic structural encodings | WD5 moves Dict, RunEnd, Sparse, Constant, Masked, Chunked and Interleave above Widen. The earlier plan to merge chunked and interleaved inputs under a top-level Widen is dropped (D25). |
The compare shortcut is the reason a decimal child dtype must always come from the values. A buffer width alone does not give a precision (an i32 buffer can hold 2,000,000,000, which needs precision 10), so a child labeled Decimal(9, 2) without a check could hold values above its precision, and the shortcut would return wrong results for them.
Serialization
The first WidenPlugin (#10946) used the separate plugin read and write IDs from #11057 to write a concrete decimal child as vortex.decimal under the parent dtype. #10995 added the reader for noncanonical decimal widths. Those reads scan the valid values because the stored statistics arrive after the plugin returns.
The plugin now reads and writes vortex.widen (#11597). The metadata names the child PType for an integer or the child precision for a decimal. The parent supplies scale and nullability. A concrete decimal child still writes vortex.decimal. Integer and encoded decimal children write vortex.widen, which requires an edition that permits the ID.
Relation to DecimalByteParts v2
Both IDs are available in the experimental unstable edition (#11615). The plan still promotes them together to preview and later to core.
DecimalByteParts owns decimal narrowing. In #11459 the MSP has a logical integer width fixed by the decimal precision, capped at i64. A narrower MSP is an integer Widen, and the existing v1 and v2 wire forms store its child directly. The planned Narrow compressor scheme (WR3) applies to integers.
DecimalByteParts v1 stores values that fit in 64 bits. V2 splits wider values into an MSP and non-nullable u64 lower parts (#11458). The v2 reader now requires lower parts and rejects node buffers (#11596). between and aggregates still decode to canonical form when lower parts exist (#11595). #11615 allowed these paths in unstable. Whether preview waits for faster kernels remains open.
Steps
- Integer
Widenin memory, with compute forwarding (rewrite of feat(array): add Narrow integer encoding #10223 and feat(array): push arithmetic and selection through Narrow #10332) - Replace
PrimitiveArrayExt::narrowwithWidenArray::encode_valuesfor internal children such as list offsets and dictionary codes (first part of feat(compress): retain Narrow integer children through compression #10333) - Benchmarks for compute over integer
Widen(Add compute benchmarks forWiden#10888) - Benchmarks for compute over decimal
Widen(Support decimal values in Widen #10946) - Decimal
Widenin memory (needed by Tracking Issue: Fix Canonical Decimal #10701) - Execute integer and decimal
Widenon CUDA (feat(cuda): Execute Widen arrays on CUDA #11303) - Promote
vortex.widenand DecimalByteParts v2 to preview (Promote DecimalByteParts v2 and Widen to preview #11635). Both are available inunstable(Add DecimalByteParts v2 and Widen to the unstable edition #11615). -
Add the integerDeferred to broader integerNarrowcompressor scheme (WR3) in this rollout.Widenadoption. -
vortex.widenandDecimalBytePartsv2 in acoreedition
PR plan (agents keep this list up to date)
The IDs below match the implementation plan. The briefs describe each PR. When a PR opens, add its link. When it merges, tick its box. When its scope changes, add a short note here.
- FX3 Dictionary
fill_nullno longer truncates the fill code (brief). Needs: none. Avoid truncating dictionary fill codes #10745, merged on 2026-10-26, which closed Dict fill_null can truncate indices of unreferenced dictionary values #10623. Widen dictionary codes in Dict::fill_null #10806 then widens the codes instead of declining, merged on 2026-10-26 (Widen dict codes inDict::fill_null#10804) - WD1 In-memory integer
Widen, withencode, deprecatedencode_values, and a flatten rule. Add an in-memoryWidenencoding for integers #10864, merged on 2026-10-28. Support decimal values in Widen #10946 (merged on 2026-11-03) includes the writer work folded from Write Widen arrays through an array plugin #11002: the default session registers a writer-only plugin for decimalWidenleaves usingvortex.decimal, without executing arrays. IntegerWidenserialization still requires explicit caller preparation until upstream normalization or its own wire form is available. - WD2 Benchmarks for compute on integer
Widen. Needs: WD1. Add compute benchmarks forWiden#10888, merged on 2026-10-28 - WD3 Aggregates run on the child. Needs: WD2. Compute
Widenaggregates on the values #10890, merged on 2026-10-28 - WD4 Arithmetic,
between,zipand casts run on the child. Needs: WD3. RunWidenarithmetic, cast, fill null, zip and between on the values #10891, merged on 2026-10-28. Follow-up:ZipExecuteAdaptordispatches only on theif_truebranch #10908, so that aWidenin theif_falsebranch ofzipalso runs on the child (fixed by Dispatch zip kernels on either value branch #11138) - WD5 Structural encodings move above
Widen, and dictionary codes use the child. Needs: WD4, FX3. Deferred. - Decimal dictionary values (D25). Normalize
Widen(Dict(codes, values))toDict(codes, Widen(values)). Preserve the codes and value-table nullability. Verify that a concrete decimal value table writes with the legacyvortex.dictandvortex.decimalIDs. Draft Normalize arrays for restricted-edition writes #11637 adds the rewrite. Coordinate value-table compression with Dictionary encode decimals #11332. - WD6 The existing narrowing call sites move to
encode_values. Needs: WD1, not WD5. [EXPERIMENT] Narrow internal children withencode_values#10943 closed without merging on 2026-11-03. The migration is deferred. The draft records the signedness changes, the old-reader comparison, and the remaining performance and CUDA validation - Decimal
Widenin memory (CD4) is in Tracking Issue: Fix Canonical Decimal #10701. Support decimal values in Widen #10946, Push decimal comparisons, between, and fills through Widen #11003, Push decimal aggregates through Widen #11004, and Export decimal Widen arrays to Arrow with one copy #10994 merged on 2026-11-03. Add shared conversion to canonical decimal arrays or Widen #11005 and Keep same-scale decimal widening casts lazy #11006 merged on 2026-11-04. Write Widen arrays through an array plugin #11002 closed and its writer work moved into Support decimal values in Widen #10946. The plugin prerequisite Separate the read and write IDs of array plugins #11057 merged on 2026-11-02 - WR1
vortex.widenwire format for integers and decimals. Add a wire format for Widen arrays #11597 merged on 2026-11-19. A concrete decimal child still writesvortex.decimal. Writes of other children require an edition that permitsvortex.widen. - WR2p DecimalByteParts v2 rejects node buffers and requires at least one lower part. Reject DecimalByteParts v2 shapes that the writer never emits #11596 merged on 2026-11-18.
- WR2 Draft Promote DecimalByteParts v2 and Widen to preview #11635 moves
vortex.widenand DecimalByteParts v2 intopreview2026.11.0. Needs: WR1, WR2p, CD5, and CD7 (Tracking Issue: Fix Canonical Decimal #10701). Add DecimalByteParts v2 and Widen to the unstable edition #11615 enabled both formats inunstableon 2026-11-19. Coordinate the v2 reader contract with open Harden serde of unstable encodings and the list layout, and document wire-contract design #11442 before preview. - WR3 An integer
Narrowscheme in the compressor that producesWidenarrays. Deferred. Needs a design pass before adoption. Needs: WR1, WR2, WD5, CD3, CD4, CD7. A scheme that compresses its child through another scheme declares and refines that scheme, as the FoR scheme does sinceFoRScheme: declare and refine its bit-packed child #10757 - LT1 Add
vortex.widenand DecimalByteParts v2 to acoreedition and add compatibility fixtures. - Restricted-edition writes. Draft Normalize arrays for restricted-edition writes #11637 checks the wire ID returned by each serializer. If the target disallows it, try structural rewrites first and execute the remaining rejected subtree as needed. This applies to any array encoding. A dictionary or run-end array can keep its structure while the writer prepares its values. Research notes.
Follow-up issues found while planning:
- Keep generic structural encodings above other encodings #10748 Keep generic structural encodings above other encodings. WD5 does this for
Widenonly - FoR scheme bit-packs its child outside the allowed schemes #10751 The FoR scheme bit-packed its child outside the allowed schemes. Fixed by
FoRScheme: declare and refine its bit-packed child #10757 -
ZipExecuteAdaptordispatches only on theif_truebranch #10908 The zip adaptors dispatch only onif_true, so an encodedif_falsebranch misses its kernel. Fixed by Dispatch zip kernels on either value branch #11138, merged on 2026-11-03
Unresolved questions
- Should we store the entire
DecimalDTypein theWidenmetadata, which includesscale? It is kind of pointless because the scale is always the same, but it also doesn't really hurt.- No, the metadata stores only the child precision. The scale and nullability of the child always equal those of the parent, so storing them only lets a file hold an invalid child. The format is in no edition yet, so this can still change.
- Should
ListandListViewoffsets always have anI64dtype, withWidenproviding the narrow physical width? (From the discussion on Epic: Implement Narrow integer encoding #10020.)
Implementation history
- Research: [DO NOT MERGE] Research notes on extension types and casts #10633 and [DO NOT MERGE] Research notes on Decimal,
Widen, and the type roadmap #11237 - feat(array): add Narrow integer encoding #10223
- feat(array): push arithmetic and selection through Narrow #10332
- feat(compress): retain Narrow integer children through compression #10333
- Avoid truncating dictionary fill codes #10745: dictionary
fill_nullno longer truncates the fill code (FX3) - Widen dictionary codes in Dict::fill_null #10806: dictionary
fill_nullwidens the codes instead of declining (follow-up of FX3) - Renamed from
NarrowtoWidenon 2026-10-28. - Add an in-memory
Widenencoding for integers #10864: in-memory integerWiden(WD1) - Add compute benchmarks for
Widen#10888: compute benchmarks forWiden(WD2) - Compute
Widenaggregates on the values #10890:Widenaggregates run on the child (WD3) - Run
Widenarithmetic, cast, fill null, zip and between on the values #10891:Widenarithmetic, cast, fill null, zip and between run on the child (WD4) - Separate the read and write IDs of array plugins #11057 (2026-11-02): separate plugin read and write IDs, so a
Widenwriter can emit existing wire forms without claiming their readers - Support decimal values in Widen #10946 (2026-11-03): decimal values in
Widen, with a writer-only plugin for decimal leaves (CD4 in Tracking Issue: Fix Canonical Decimal #10701) - Dispatch zip kernels on either value branch #11138 (2026-11-03):
zipkernels dispatch on either value branch, which fixesZipExecuteAdaptordispatches only on theif_truebranch #10908 - Push decimal comparisons, between, and fills through Widen #11003, Export decimal Widen arrays to Arrow with one copy #10994, and Push decimal aggregates through Widen #11004 (2026-11-03): decimal compare,
between, fills, Arrow export, and aggregates onWiden(CD4 and CD4b in Tracking Issue: Fix Canonical Decimal #10701) - Add shared conversion to canonical decimal arrays or Widen #11005 (2026-11-04):
WidenArray::from_stored_decimalconverts stored decimal values into the canonical array or a decimalWiden(CD4 in Tracking Issue: Fix Canonical Decimal #10701) - Keep same-scale decimal widening casts lazy #11006 (2026-11-04): same-scale decimal widening casts return a
Widen(CD4 in Tracking Issue: Fix Canonical Decimal #10701) - Read legacy vortex.decimal nodes into the canonical array or a Widen #10995 (2026-11-05) reads narrow
vortex.decimalnodes into a canonical decimal or a decimalWiden. - feat(cuda): Execute Widen arrays on CUDA #11303 (2026-11-10) executes integer and decimal
Widenon CUDA, a prerequisite for using a narrow integer MSP in DecimalByteParts. - Keep the DecimalByteParts MSP at its logical integer width #11459 (2026-11-17) keeps a narrower DecimalByteParts MSP as an integer
Widen, and addsWidenArray::from_stored_integerandWidenArray::to_stored_integer. - Require canonical storage width for decimal arrays #11571 (2026-11-18) requires the canonical width for every decimal array, so a narrower decimal is always a
Widen(CD8a in Tracking Issue: Fix Canonical Decimal #10701). - Keep only fastlanes.delta in the unstable edition #11595 (2026-11-18) removed DecimalByteParts v2 from
unstable. - Reject DecimalByteParts v2 shapes that the writer never emits #11596 (2026-11-18) makes the v2 reader accept only shapes that the writer emits.
- Add a wire format for Widen arrays #11597 (2026-11-19) adds the
vortex.widenwire format. - Add DecimalByteParts v2 and Widen to the unstable edition #11615 (2026-11-19) enables both formats in
unstable.
Activity
Avoid truncating dictionary fill codes (#10745)
Update the Narrow and decimal research for the first PRs
Update the Narrow and decimal research for the first PRs
[-]Tracking Issue: Add `Narrow` encoding for integers and decimals[/-][+]Tracking Issue: Add `Widen` encoding for integers and decimals[/+]Keep the DecimalByteParts MSP at its logical integer width (#11459)
Reject node buffers in DecimalByteParts v2 (#11596)
Add a wire format for Widen arrays (#11597)
Ignore trailing children and buffers in DecimalByteParts v2 and Widen (…
Promote DecimalByteParts v2 and Widen to preview (#11635)