lance-format / lance-format/lance

[feat] better support for filterable torch samplers

Open
#1,947 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Rust
Stars
7.1k
Forks
852
Avg merge
3d 18h
Merged PRs (30d)
272

Description

Currently the ShardedBatchSampler does not support a filter. This is because it assigns index ranges to processes before scanning and, if we apply the filter during the scan, that will result in different processes getting a different number of rows. However, sampling and filtering is something we'd like to be able to support.

  1. If the user knows the filter is not very selective (or the filtered rows are evenly distributed throughout the dataset) then we should let them use the ShardedBatchSampler with a filter. The result will not be too far from ideal. This would require us to support a filtered "take scan" which we do not have today.

  2. We can use a reservoir sampler to jitter the inputs. With a large enough reservoir the result should be significantly reordered even if it isn't perfectly random.

  3. We can first do a filtered scan to row ids (which could be stored as a compressed bitmap), shuffle the row ids, and then divide the shuffled ranges amongst the inputs. This will be the most random and balanced solution but it will require materializing the row ids.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the ShardedBatchSampler and the scan and filter paths it uses. Compare the filtered take scan, reservoir sampling, and materialized row-ID approaches, then define which approach should be implemented; done means filtered sampling works across processes with acceptable balance and reordering.

Written by the indexing model from the issue text.

Assessment

Tech stack
pytorch, rust
Domain
machine-learning
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.