Fix TypeError when disabling on-device sampling#28
Open
tmuttaki wants to merge 1 commit intovllm-project:release-0.4.1from
Open
Fix TypeError when disabling on-device sampling#28tmuttaki wants to merge 1 commit intovllm-project:release-0.4.1from
tmuttaki wants to merge 1 commit intovllm-project:release-0.4.1from
Conversation
Fixed incorrect import of Sampler class that caused a TypeError when NEURON_ON_DEVICE_SAMPLING_DISABLED=1 was set or when on_device_sampling_config was explicitly set to None. The bug occurred because the code was importing the sampler module instead of the Sampler class: - Before: from vllm.v1.sample import sampler as Sampler - After: from vllm.v1.sample.sampler import Sampler This caused a "TypeError: 'module' object is not callable" error when trying to instantiate the sampler at line 81. This fix enables CPU sampling mode, which is required for structured outputs and grammar-constrained generation that are not supported by on-device sampling. Tested on AWS Trainium (trn1.2xlarge) with TinyLlama-1.1B-Chat-v1.0 using structured output via response_format parameter. Signed-off-by: Tahmid Muttaki <tmuttaki@redhat.com>
4daa543 to
0d6b1cb
Compare
Author
|
Fixes #29 |
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.
Summary
Fixed incorrect import of
Samplerclass that caused aTypeErrorwhen on-device sampling was disabled.Fixes #29
Problem
When
NEURON_ON_DEVICE_SAMPLING_DISABLED=1environment variable is set or whenon_device_sampling_configis explicitly set toNonein the Neuron config overrides, the server fails to start with:Root Cause
Line 54 in
vllm_neuron/worker/neuronx_distributed_model_loader.pywas importing thesamplermodule instead of theSamplerclass:This imported the module object, which cannot be called as a constructor.
Solution
Changed the import to correctly import the
Samplerclass:Testing
Tested on AWS Trainium (trn1.2xlarge) with TinyLlama-1.1B-Chat-v1.0:
NEURON_ON_DEVICE_SAMPLING_DISABLED=1response_formatparameter using JSON schemasExample structured output test:
Result:
{ "name": "John Doe", "age": 30, "city": "New York" }Impact
Related Issues
This fix enables users to:
response_formatparametertemperature,top_k, andtop_p