Feat/sequence cast compute#8403
Conversation
SequenceArray previously used the same ptype for arithmetic and for the declared output dtype, which made the model too narrow for casts. Store calculation_ptype separately from the output dtype, preserve it through metadata, and validate that generated values fit the declared output type. Update decompression, filter, take, slice, scalar access, and min/max paths to compute in calculation_ptype while emitting values using the array output ptype. Signed-off-by: Siddarth Gundu <siddarthg0910@gmail.com>
Sequence::try_new now accepts both the calculation ptype and output ptype. Signed-off-by: Siddarth Gundu <siddarthg0910@gmail.com>
|
Don't worry about the rustsec issue, that is a known problem |
Merging this PR will not alter performance
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Simulation | decompress_rd[f64, (100000, 0.01)] |
845.9 µs | 981.6 µs | -13.83% |
| ❌ | Simulation | decompress_rd[f64, (100000, 0.1)] |
845.9 µs | 981.6 µs | -13.82% |
| ⚡ | Simulation | decompress_rd[f64, (100000, 0.0)] |
1,024.6 µs | 845.9 µs | +21.12% |
| ⚡ | Simulation | decompress_rd[f32, (100000, 0.0)] |
586.8 µs | 499.3 µs | +17.51% |
| ⚡ | Simulation | bitwise_not_vortex_buffer_mut[128] |
244.4 ns | 215.3 ns | +13.55% |
| ⚡ | Simulation | bitwise_not_vortex_buffer_mut[1024] |
304.7 ns | 275.6 ns | +10.58% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing siddarth2810:feat/sequence-cast-compute (c73544f) with develop (9444d20)
Footnotes
-
10 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
gatesn
left a comment
There was a problem hiding this comment.
It's a good catch that this was broken before.
But why is it important to store this information? Vs just always computing in i64/u64 space?
Thanks for the quick review :) The maintainer in the previous PR mentioned to use two ptypes, so I went ahead with that design in mind. But after experimenting a bit on this, I think we could get For deserialization, I think we can use scalar kind before decoding the scalar, so we may not need to store |
Summary
This PR updates
SequenceArrayto track the arithmetic ptype separately from the declared output dtype.Previously,
SequenceArrayused the sameptypefor both calculation and output. Cases like a negative-step signed sequence where all generated values still fit an unsigned output dtype failed.This change stores
calculation_ptypein theSequenceMetadata, validates generated values against the output dtype, and updates sequence paths to compute usingcalculation_ptypewhile emitting values using the array output ptype.After casting, a
SequenceArraycan compute internally as i32 while exposing u8 as its array dtype. Added a test that catchesscalar_atreturning an i32 PValue inside a u8 scalar.Closes: #5102
API Changes
Sequence::try_newandSequence::new_uncheckednow accept both calculation_ptype and output_ptype.Testing
For testing code changes
For testing the build
AI tools Disclosure
Used ChatGPT for understanding code and OpenCode for updating callers and generating tests