OnPair trainer should draw Rust's sample (StdRng + partial_shuffle) for byte-identical dictionaries
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 22/100
Research direction
Start in OnPairEncodingEncoder.Encoder.train, which uses SplittableRandom(42) and a full Fisher-Yates shuffle, and compare it with the Rust training_order in encoding/trainer.rs. Port the partial_shuffle tail selection and doubling retry loop on top of SampleRng, and check that SampleRng.nextIntInclusive matches random_range from rand 0.9.5. Done when the 100k-row URL column gives the same dict_bytes_len and encoded size per chunk as the Rust 0.88.0 oracle.
Written by the indexing model from the issue text.
Description
Problem
OnPairEncodingEncoder does not draw the same training sample as the Rust onpair crate, so it trains different dictionaries on identical data. Prime directive: behavioral parity with Rust.
Found by comparing a 100k-row URL column (https://example.com/products/<n>/reviews?page=<m>, 7 chunks of 16,384 rows) written by vortex-java and by Rust 0.88.0 (the release vortex-jni uses), both at cascade 3 with global dict off. Both pick vortex.onpair per chunk.
dict_bytes_len per chunk:
| chunk | Rust | Java |
|---|---|---|
| 0 | 8191 | 8429 |
| 1 | 8525 | 8368 |
| 2 | 8447 | 8387 |
| 3 | 8363 | 8452 |
| 4 | 8379 | 8473 |
| 5 | 8757 | 5670 |
| 6 | 1872 | 1877 |
Chunks 0-4 end up within 0.04% in total, but Java's chunk 5 is 18% smaller (131,904 B vs 161,507 B): its trainer built a 761-token dictionary and the cascade then dict-encoded the 467 distinct codes. That one chunk is 29.6 KB of the 31.6 KB (3.2%) by which Java's file is smaller. This is training luck, not a systematic advantage, and it could go the other way on other data.
Cause
- Rust (
onpair0.2.1,training_orderinencoding/trainer.rs):StdRng::seed_from_u64(42)(ChaCha12,rand0.9.5) andorder.partial_shuffle(&mut rng, k)withk = min(n, 2 * sample_fraction * n + 1024). Training consumes only the selected tailorder[n-k..]; if that tail is shorter than the byte budget,kdoubles and the shuffle restarts. - Java (
OnPairEncodingEncoder.Encoder.train):SplittableRandom(42), a full Fisher-Yates shuffle, and training consumesorderfrom the start.
Proposed fix
- Port
rand0.9.5partial_shuffleon top ofSampleRng(already a bit-exact ChaCha12StdRngandrandom_rangeforu32). It usesIncreasingUniform/calculate_bound_u32, which batches several swaps into one random chunk. Check thatSampleRng.nextIntInclusive(written againstrand0.10) gives the same values as 0.9.5'srandom_range. - Reproduce the
kcomputation, the tail consumption and the doubling retry loop intrain. - Parity test: the URL column above, Rust as the oracle, comparing
dict_bytes_lenand encoded size per chunk (expect identical).
Repro
Scratch crate with vortex = "=0.88.0"; data dumped from the Java CascadeDepthGainIntegrationTest patterns (utf8-urls), seed 42. Not committed.
- Dominant language
- Java
- Stars
- 3
- Forks
- 2
- Avg merge
- 9h 19m
- Merged PRs (30d)
- 154
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dfa1/vortex-java
-
good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
dfa1/vortex-java#738 ·
Maintainers usually reply within 1 day
-
good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
dfa1/vortex-java#737 ·
Maintainers usually reply within 1 day
-
good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
dfa1/vortex-java#736 ·
Maintainers usually reply within 1 day
-
help wanted project
Difficulty 5/5 Over a week Newbie friendliness 25/100
dfa1/vortex-java#729 ·
Maintainers usually reply within 1 day
-
enhancement good first issue
Difficulty 3/5 1-2 days Newbie friendliness 72/100
dfa1/vortex-java#728 ·
Maintainers usually reply within 1 day
All issues in dfa1/vortex-java
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
-
Difficulty 2/5 Under an hour Newbie friendliness 84/100
cpp-best-practices/project_validator#251 ·
Maintainers usually reply within 1 day
-
backend enhancement
Difficulty 2/5 Half a day Newbie friendliness 70/100
damodharg6/payledger#16 ·
-
[Bug]: An initiative list with no current entry logs an error on every changePossibly taken @dwizard0 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
Maintainers usually reply within 1 day