lazy import for vllm benchmark#129
Merged
Merged
Conversation
liusong1222
approved these changes
Nov 5, 2025
dawnranger
pushed a commit
to dawnranger/AngelSlim
that referenced
this pull request
Mar 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request refactors how external dependencies are imported in the benchmarking code for speculative decoding, focusing on lazy imports for improved modularity and startup performance. The main changes involve switching direct imports of
fastchat,shortuuid, andvllmto use the newangelslim.utils.lazy_importsmodule, and updating code to reference these modules accordingly. This change helps avoid unnecessary imports when modules are not used, and sets up the codebase for easier dependency management.Dependency import refactoring:
fastchat,shortuuid, andvllmingenerate_baseline_answer.pyandgenerate_eagle_answer.pywith lazy imports fromangelslim.utils.lazy_imports, and updated all usages to reference these lazy-loaded modules. [1] [2] [3]LLMandSamplingParamsfromvllmto usevllm.LLMandvllm.SamplingParamsvia the lazy import, including type hints and instantiations. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]Benchmark engine updates:
load_questionsfromfastchat.llm_judge.commonto referencefastchat.llm_judge.common.load_questionsvia the lazy import inbenchmark_engine.py,generate_baseline_answer.py, andgenerate_eagle_answer.py. [1] [2] [3] [4] [5]Requirements update:
vllm>=0.11.0torequirements/requirements_speculative.txtto ensure the required version is installed for lazy loading.Miscellaneous:
from __future__ import annotationsat the top ofgenerate_baseline_answer.pyandgenerate_eagle_answer.pyto support postponed evaluation of type annotations, which helps with forward references and lazy imports. [1] [2]shortuuidandvllmfrom the affected files, cleaning up the codebase. [1] [2]Let me know if you'd like to discuss how lazy imports work or why this change improves the codebase!