Repository navigation
refactor: llguidance - #288
Conversation
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🟢 Enforce conventional commitWonderful, this rule succeeded.Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
|
jakelorocco
left a comment
There was a problem hiding this comment.
Looks like there's some mypy errors as well.
I don't know why there is a mypy error. Mypy passes locally for me. |
3ebb8bd to
8dce1f2
Compare
We've seen this happen recently and it came down to mypy versions. Could be the cause. I re-ran the checks on the latest branch. If those still fail and you still pass with mypy, try checking your mypy version. |
|
With an updated lockfile the mypy passes. Test is terminated but locally it is passing. If you approve, I will merge this |
938d919 to
62923fe
Compare
There was a problem hiding this comment.
@guicho271828, can you remind me if we ever got the local vllm backend running on mac (or if you remember a discussion about that)?
I tried installing this version of the mellea package on my mac and was getting versioning errors.
Details
(mellea) ➜ mellea git:(pr/guicho271828/288) uv pip install -e '.[all]' --all-extras --group dev -r pyproject.toml
Using Python 3.12.0 environment at: /opt/homebrew/Caskroom/miniforge/base/envs/mellea
× No solution found when resolving dependencies:
╰─▶ Because only the following versions of nvidia-cudnn-frontend are available:
nvidia-cudnn-frontend<=1.13.0
nvidia-cudnn-frontend==1.14.0
nvidia-cudnn-frontend==1.14.1
nvidia-cudnn-frontend==1.15.0
nvidia-cudnn-frontend==1.16.0
nvidia-cudnn-frontend==1.17.0
and nvidia-cudnn-frontend>=1.13.0 has no wheels with a matching platform tag (e.g., `macosx_15_0_arm64`), we can conclude that
nvidia-cudnn-frontend>=1.13.0 cannot be used.
And because flashinfer-python==0.5.3 depends on nvidia-cudnn-frontend>=1.13.0 and vllm==0.13.0 depends on flashinfer-python==0.5.3, we
can conclude that vllm==0.13.0 cannot be used.
And because only vllm<=0.13.0 is available and mellea depends on vllm>=0.13.0, we can conclude that your requirements are
unsatisfiable.
It looks like the newest version I can install on a mac is 0.11.0.
The vllm engine can't seem to get enough resources to run locally on my mac anyways, so maybe we can just add a note somewhere that "mella[vllm]" doesn't work for macs?
To run vllm locally, vllm assumes
So yes |
29588fb disables installing vllm on darwin. |
27a9159 to
91a9e1a
Compare
jakelorocco
left a comment
There was a problem hiding this comment.
Please also confirm that the huggingface / vllm tests run with the most recent changes.
| device = torch.device("mps") | ||
| model = AutoModelForCausalLM.from_pretrained(model_id).to(device) | ||
| model = AutoModelForCausalLM.from_pretrained(model_id) | ||
| # model = model.to(device=device) # this part does not pass mypy; possible misconfiguration |
There was a problem hiding this comment.
This code does not pass mypy and this error existed from before, it is not written by me.
Annoyingly, without fixing this, I cannot commit any changes with pre-commit enabled, especially because now all code in docs/ are also checked by pre-commit.
d3c9044 to
81ee868
Compare
|
Two huggingface tests failed which are out of scope of this PR.
-> structured output failure due to a weak model
-> test for error handling, discussed in #432 One vllm test failed.
-> structured output failure due to a weak model |
…e is any env name with "mellea"
…, disable vllm on osx
…, disable vllm on osx
…, disable vllm on osx
81ee868 to
6b558b5
Compare
6205b36
* fix(conda): conda should not always supersede mamba * fix(conda): fixed existing conda environment detection; fails if there is any env name with "mellea" * refactor: outlines -> llguidance on vllm/hf, vllm 0.13, V1 API, disable vllm on osx * fix: revert BaseModelSubclass default value * fix: removed unused Generic from ReactInitiator * fix(docs): pass docs/kv_smash/kvcache.py * fixup! fix: revert BaseModelSubclass default value * fixup! refactor: outlines -> llguidance on vllm/hf, vllm 0.13, V1 API, disable vllm on osx * fixup! refactor: outlines -> llguidance on vllm/hf, vllm 0.13, V1 API, disable vllm on osx * fixup! refactor: outlines -> llguidance on vllm/hf, vllm 0.13, V1 API, disable vllm on osx
… calls
With whitespace_flexible=False (compact JSON), llguidance constructs a grammar
where the highest-probability token after opening an array '[' is immediately
']', silently collapsing structured output to empty arrays (e.g.
{"result":[]}) under greedy decoding. No exception is raised and the caller
cannot distinguish a correct empty list from a grammar-induced collapse.
This bug was introduced in PR generative-computing#288 as a mechanical outlines->llguidance port.
The llguidance library's own default for whitespace_flexible is True; the
original False was never intentional.
Fix all three grammar_from_json_schema call sites in LocalHFBackend:
- _generate_from_context_with_kv_cache
- _generate_from_context_standard
- _generate_from_raw
Regression tests added for all three call sites (mock-based, no real model).
Fixes generative-computing#1510
Assisted-by: IBM Bob
Signed-off-by: Nigel Jones <[email protected]>
…prevent silent array collapse (generative-computing#1513) * fix(hf): set whitespace_flexible=True in all grammar_from_json_schema calls With whitespace_flexible=False (compact JSON), llguidance constructs a grammar where the highest-probability token after opening an array '[' is immediately ']', silently collapsing structured output to empty arrays (e.g. {"result":[]}) under greedy decoding. No exception is raised and the caller cannot distinguish a correct empty list from a grammar-induced collapse. This bug was introduced in PR generative-computing#288 as a mechanical outlines->llguidance port. The llguidance library's own default for whitespace_flexible is True; the original False was never intentional. Fix all three grammar_from_json_schema call sites in LocalHFBackend: - _generate_from_context_with_kv_cache - _generate_from_context_standard - _generate_from_raw Regression tests added for all three call sites (mock-based, no real model). Fixes generative-computing#1510 Assisted-by: IBM Bob Signed-off-by: Nigel Jones <[email protected]> * fix(hf): address reviewer feedback on generative-computing#1513 - Rewrite regression tests to model each method's actual async control flow instead of swallowing exceptions with a silent try/except. - Hoist the llguidance grammar defaults into a module constant typed as JsonCompileOptions (imported under TYPE_CHECKING from the private llguidance._lib submodule, since it isn't re-exported publicly) to keep mypy accurate without resorting to Any. - Remove dead mock setup (allocate_token_bitmask, unused LLMatcher return value) left over from the old test scaffolding. - Document the whitespace_flexible=True token overhead in the HF integration guide. Assisted-by: Claude Code Signed-off-by: Nigel Jones <[email protected]> * fix(hf): also set whitespace_flexible=True in the m serve grammar call The chat_completion_request_to_transformers_inputs() grammar_from_json_schema() call (the OpenAI-compatible /chat/completions path used by m serve) omitted defaults entirely. JsonCompileOptions.whitespace_flexible's docstring claims it "defaults to true" when omitted, but empirically it does not: omitting defaults produces no explicit whitespace_flexible setting at all, and falls through to the underlying JsonCompiler's real default of False -- so this call site was exposed to the same generative-computing#1510 collapse bug as the three already-fixed call sites in LocalHFBackend. Assisted-by: Claude Code Signed-off-by: Nigel Jones <[email protected]> * fix(hf): correct whitespace_flexible defeatability and dedupe constant - overrides= instead of defaults= at the m serve grammar call site, since its schema comes straight off the wire and a caller could otherwise embed x-guidance.whitespace_flexible=false to defeat a defaults= pass - move _LLGUIDANCE_GRAMMAR_DEFAULTS to util.py as the single definition, imported by huggingface.py instead of duplicated - correct util.py comment: llguidance's own default is already True when defaults is omitted, so the m serve call site was never affected by generative-computing#1510 - fix test mock signature regression from the overrides= swap, and a stale test comment - reword docs token-overhead note to match Assisted-by: Claude Code Signed-off-by: Nigel Jones <[email protected]> * fix(hf): set bounded whitespace_pattern to prevent silent array collapse and runaway spaces Address review feedback from Jake LoRocco on generative-computing#1513. Replacing whitespace_flexible: True with a bounded whitespace_pattern: r"[\x20\x0A\x0D\x09]{0,20}". This allows spaced/pretty JSON (preventing the silent array collapse bug generative-computing#1510) and safely accommodates 4-space indentation up to 4 levels of nesting, while establishing an absolute hard limit of 20 consecutive characters of whitespace to completely prevent infinite or runaway whitespace generation. Assisted-by: IBM Bob Signed-off-by: Nigel Jones <[email protected]> * docs(hf): update huggingface documentation for bounded whitespace_pattern Assisted-by: IBM Bob Signed-off-by: Nigel Jones <[email protected]> --------- Signed-off-by: Nigel Jones <[email protected]>
No description provided.