Skip to content

Conversation

@Ofir408
Copy link

@Ofir408 Ofir408 commented Nov 27, 2025

Optimize calibrate_draft_vocab to read only required lines when calibrate_size is set

What does this PR do?

Type of change: Performance improvement

Overview:
This PR optimizes the calibrate_draft_vocab.py script to improve memory efficiency and I/O performance when using the --calibrate_size parameter. Previously, the script would read all lines from the data file into memory before slicing to the specified calibrate_size, causing unnecessary resource usage for large datasets. The optimization uses itertools.islice to read only the required number of lines when calibrate_size is specified.

Usage

The script usage remains unchanged. When using --calibrate_size, the script now only reads the specified number of lines instead of loading the entire dataset:

# Only reads first 1000 lines from the dataset (optimized)
python scripts/calibrate_draft_vocab.py \
    --model meta-llama/Llama-3.2-1B-Instruct \
    --data input_conversations/daring-anteater.jsonl \
    --draft_vocab_size 32000 \
    --calibrate_size 1000 \
    --save_dir draft_vocab_cache

@Ofir408 Ofir408 requested a review from a team as a code owner November 27, 2025 13:50
@Ofir408 Ofir408 requested a review from ChenhanYu November 27, 2025 13:50
@copy-pr-bot
Copy link

copy-pr-bot bot commented Nov 27, 2025

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@Ofir408 Ofir408 force-pushed the feature/optimize-calibrate-vocab-reading branch from a271623 to a3bc080 Compare November 27, 2025 13:57
@codecov
Copy link

codecov bot commented Dec 1, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.64%. Comparing base (fa84955) to head (cdd0be5).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #618   +/-   ##
=======================================
  Coverage   74.64%   74.64%           
=======================================
  Files         183      183           
  Lines       18542    18542           
=======================================
  Hits        13840    13840           
  Misses       4702     4702           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants