Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: outlines import errors #850

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions aphrodite/modeling/guided_decoding/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,15 @@
GuidedDecodingRequest)
from aphrodite.triton_utils import HAS_TRITON

if HAS_TRITON:
from aphrodite.modeling.guided_decoding.outlines_decoding import (
get_local_outlines_guided_decoding_logits_processor,
get_outlines_guided_decoding_logits_processor)


async def get_guided_decoding_logits_processor(
guided_decoding_backend: str, request: Union[CompletionRequest,
ChatCompletionRequest],
tokenizer) -> Optional[LogitsProcessorFunc]:
request = _adapt_request_for_tool_use(request)
if guided_decoding_backend == 'outlines':
from aphrodite.modeling.guided_decoding.outlines_decoding import (
get_outlines_guided_decoding_logits_processor)
if HAS_TRITON:
return await get_outlines_guided_decoding_logits_processor(
request, tokenizer)
Expand All @@ -42,6 +39,8 @@ def get_local_guided_decoding_logits_processor(
# request = _adapt_request_for_tool_use(request)

if guided_decoding_backend == 'outlines':
from aphrodite.modeling.guided_decoding.outlines_decoding import (
get_local_outlines_guided_decoding_logits_processor)
return get_local_outlines_guided_decoding_logits_processor(
guided_options, tokenizer)
if guided_decoding_backend == 'lm-format-enforcer':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@
from aphrodite.modeling.guided_decoding.lm_format_enforcer_logits_processors import ( # noqa: E501
build_aphrodite_logits_processor,
build_aphrodite_token_enforcer_tokenizer_data)
from aphrodite.triton_utils import HAS_TRITON

if HAS_TRITON:
from aphrodite.modeling.guided_decoding.outlines_decoding import (
get_local_outlines_guided_decoding_logits_processor,
get_outlines_guided_decoding_logits_processor)


async def get_lm_format_enforcer_guided_decoding_logits_processor(
Expand All @@ -46,6 +40,9 @@ async def get_lm_format_enforcer_guided_decoding_logits_processor(
elif request.guided_regex:
character_level_parser = RegexParser(request.guided_regex)
elif request.guided_grammar:
from aphrodite.modeling.guided_decoding.outlines_decoding import (
get_outlines_guided_decoding_logits_processor)

# CFG grammar not supported by LMFE, revert to outlines
return await get_outlines_guided_decoding_logits_processor(
request, tokenizer)
Expand Down Expand Up @@ -83,6 +80,9 @@ def get_local_lm_format_enforcer_guided_decoding_logits_processor(
elif guided_options.guided_regex:
character_level_parser = RegexParser(guided_options.guided_regex)
elif guided_options.guided_grammar:
from aphrodite.modeling.guided_decoding.outlines_decoding import (
get_local_outlines_guided_decoding_logits_processor)

# CFG grammar not supported by LMFE, revert to outlines
return get_local_outlines_guided_decoding_logits_processor(
guided_options, tokenizer)
Expand Down