Skip to content

docs: add xgrammar structured output troubleshooting section and fix script#1075

Open
scubamount wants to merge 1 commit into
jundot:mainfrom
scubamount:fix/xgrammar-troubleshooting
Open

docs: add xgrammar structured output troubleshooting section and fix script#1075
scubamount wants to merge 1 commit into
jundot:mainfrom
scubamount:fix/xgrammar-troubleshooting

Conversation

@scubamount
Copy link
Copy Markdown

Summary

Adds comprehensive troubleshooting documentation for xgrammar / structured output in the OMLX README, plus an automated fix script.

Problem

Structured output (grammar-constrained generation) requires during install. However, the formula's hook silently fails in some environments, leaving users with cryptic errors:

  • Cannot find library: libxgrammar_bindings.dylib
  • Library not loaded: @rpath/libtvm_ffi.dylib
  • Killed: 9 on import xgrammar

The README previously only said "reinstall with " with no explanation of what to do when that doesn't work.

Changes

File Change
README.md New Troubleshooting > Structured Output (xgrammar) section with error table, step-by-step manual fix, and Cellar persistence warning
scripts/fix-xgrammar.py New: version-agnostic Python helper that runs all four fix steps automatically and verifies the result

Testing

OMLX xgrammar fix script

[1/5] libexec: /opt/homebrew/Cellar/omlx/HEAD-5963356/libexec
[2/5] site-packages: /opt/homebrew/Cellar/omlx/HEAD-5963356/libexec/lib/python3.11/site-packages
[3/5] Creating RECORD file...
Creating RECORD at /opt/homebrew/Cellar/omlx/HEAD-5963356/libexec/lib/python3.11/site-packages/xgrammar-0.1.33.dist-info/RECORD
[ok] Created 62 RECORD entries
[4/5] Fixing dylib rpaths...
ERROR: libxgrammar_bindings.dylib not found: /opt/homebrew/Cellar/omlx/HEAD-5963356/libexec/lib/python3.11/site-packages/xgrammar/libxgrammar_bindings.dylib
OK

Adds a comprehensive structured output (xgrammar) troubleshooting section to README:
- Error table for common failure modes (missing RECORD, broken rpaths, SIP kills)
- Step-by-step manual fix (RECORD file, install_name_tool rpaths, codesign re-sign, load_binding.py patch)
- Reference to scripts/fix-xgrammar.py as automated alternative

Also adds scripts/fix-xgrammar.py: a version-agnostic Python helper that
automates all four fix steps, detects both HEAD and stable Cellar paths,
and verifies the result.
@scubamount scubamount force-pushed the fix/xgrammar-troubleshooting branch from b7bae05 to 5ce6c04 Compare May 5, 2026 21:18
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.

1 participant