Vectorize MarkovCorpus.sample

Open
#9 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
76/100
Issue type
Refactor
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
performance

Research direction

Read src/bitsmith/eval/corpus.py and locate MarkovCorpus.sample; then review the determinism and entropy floor tests in tests/unit/test_eval.py. Benchmark sampling 100,000 tokens and confirm it takes well under a second while the tests still pass. If the token sequence changes for a seed, regenerate committed results with make reproduce in the same PR.

Written by the indexing model from the issue text.

Description

area: benchmarks good first issue performance

MarkovCorpus.sample draws one token at a time in a Python loop, which takes a few seconds
for the 60,000 tokens bitsmith sweep uses.

Task: make sampling faster, for example by drawing all uniform numbers up front and
doing the per-step lookup with precomputed cumulative tables, or by sampling in chunks.

Files

  • src/bitsmith/eval/corpus.py
  • tests/unit/test_eval.py: the existing tests (determinism, entropy floor) must still pass

Note: if the token sequence changes for a given seed, regenerate the committed results
with make reproduce in the same PR.

Done when sampling 100,000 tokens takes well under a second on a laptop CPU.

Dominant language
Python
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Getting set up

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.

More from yashwanthdevavarapu/bitsmith

All issues in yashwanthdevavarapu/bitsmith

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.