llguidance 1.1.1__tar.gz → 1.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (193) hide show
  1. llguidance-1.2.0/.github/workflows/code-coverage.yml +62 -0
  2. {llguidance-1.1.1 → llguidance-1.2.0}/CHANGELOG.md +36 -24
  3. {llguidance-1.1.1 → llguidance-1.2.0}/Cargo.lock +6 -6
  4. {llguidance-1.1.1 → llguidance-1.2.0}/PKG-INFO +2 -2
  5. {llguidance-1.1.1 → llguidance-1.2.0}/parser/Cargo.toml +1 -1
  6. {llguidance-1.1.1 → llguidance-1.2.0}/parser/llguidance.h +6 -0
  7. {llguidance-1.1.1 → llguidance-1.2.0}/parser/src/api.rs +6 -0
  8. {llguidance-1.1.1 → llguidance-1.2.0}/parser/src/lark/lexer.rs +1 -1
  9. {llguidance-1.1.1 → llguidance-1.2.0}/parser/src/panic_utils.rs +1 -1
  10. {llguidance-1.1.1 → llguidance-1.2.0}/parser/src/tokenparser.rs +9 -5
  11. {llguidance-1.1.1 → llguidance-1.2.0}/pyproject.toml +1 -1
  12. {llguidance-1.1.1 → llguidance-1.2.0}/python/llguidance/_lib.pyi +43 -3
  13. {llguidance-1.1.1 → llguidance-1.2.0}/python/llguidance/numpy.py +14 -0
  14. {llguidance-1.1.1 → llguidance-1.2.0}/python/llguidance/torch.py +11 -0
  15. {llguidance-1.1.1 → llguidance-1.2.0}/python/torch_tests/test_matcher.py +149 -2
  16. {llguidance-1.1.1 → llguidance-1.2.0}/python_ext/Cargo.toml +1 -1
  17. {llguidance-1.1.1 → llguidance-1.2.0}/python_ext/src/llmatcher.rs +109 -0
  18. {llguidance-1.1.1 → llguidance-1.2.0}/python_ext/src/parserlimits.rs +11 -1
  19. {llguidance-1.1.1 → llguidance-1.2.0}/sample_parser/tests/common_lark_utils/mod.rs +56 -3
  20. {llguidance-1.1.1 → llguidance-1.2.0}/sample_parser/tests/test_json_arrays.rs +86 -0
  21. llguidance-1.2.0/sample_parser/tests/test_json_enum_const.rs +92 -0
  22. {llguidance-1.1.1 → llguidance-1.2.0}/sample_parser/tests/test_json_primitives.rs +245 -75
  23. llguidance-1.2.0/sample_parser/tests/test_json_schema_combinations.rs +372 -0
  24. llguidance-1.2.0/sample_parser/tests/test_json_string_format.rs +141 -0
  25. {llguidance-1.1.1 → llguidance-1.2.0}/sample_parser/tests/test_lark.rs +16 -0
  26. {llguidance-1.1.1 → llguidance-1.2.0}/scripts/bump.py +2 -3
  27. {llguidance-1.1.1 → llguidance-1.2.0}/toktrie/Cargo.toml +1 -1
  28. {llguidance-1.1.1 → llguidance-1.2.0}/toktrie_hf_downloader/Cargo.toml +1 -1
  29. {llguidance-1.1.1 → llguidance-1.2.0}/toktrie_hf_tokenizers/Cargo.toml +1 -1
  30. {llguidance-1.1.1 → llguidance-1.2.0}/toktrie_tiktoken/Cargo.toml +1 -1
  31. {llguidance-1.1.1 → llguidance-1.2.0}/.github/workflows/rust.yml +0 -0
  32. {llguidance-1.1.1 → llguidance-1.2.0}/.github/workflows/wheels.yml +0 -0
  33. {llguidance-1.1.1 → llguidance-1.2.0}/.gitignore +0 -0
  34. {llguidance-1.1.1 → llguidance-1.2.0}/CODE_OF_CONDUCT.md +0 -0
  35. {llguidance-1.1.1 → llguidance-1.2.0}/Cargo.toml +0 -0
  36. {llguidance-1.1.1 → llguidance-1.2.0}/LICENSE +0 -0
  37. {llguidance-1.1.1 → llguidance-1.2.0}/README.md +0 -0
  38. {llguidance-1.1.1 → llguidance-1.2.0}/SECURITY.md +0 -0
  39. {llguidance-1.1.1 → llguidance-1.2.0}/SUPPORT.md +0 -0
  40. {llguidance-1.1.1 → llguidance-1.2.0}/c_sample/Makefile +0 -0
  41. {llguidance-1.1.1 → llguidance-1.2.0}/c_sample/README.md +0 -0
  42. {llguidance-1.1.1 → llguidance-1.2.0}/c_sample/c_sample.cpp +0 -0
  43. {llguidance-1.1.1 → llguidance-1.2.0}/docs/de_recursing.md +0 -0
  44. {llguidance-1.1.1 → llguidance-1.2.0}/docs/fast_forward.md +0 -0
  45. {llguidance-1.1.1 → llguidance-1.2.0}/docs/json_schema.md +0 -0
  46. {llguidance-1.1.1 → llguidance-1.2.0}/docs/mask_plot.png +0 -0
  47. {llguidance-1.1.1 → llguidance-1.2.0}/docs/optimizations.md +0 -0
  48. {llguidance-1.1.1 → llguidance-1.2.0}/docs/parametric.md +0 -0
  49. {llguidance-1.1.1 → llguidance-1.2.0}/docs/special_tokens.md +0 -0
  50. {llguidance-1.1.1 → llguidance-1.2.0}/docs/syntax.md +0 -0
  51. {llguidance-1.1.1 → llguidance-1.2.0}/docs/toktrie.md +0 -0
  52. {llguidance-1.1.1 → llguidance-1.2.0}/json_stats/Cargo.toml +0 -0
  53. {llguidance-1.1.1 → llguidance-1.2.0}/json_stats/expected_maskbench.json +0 -0
  54. {llguidance-1.1.1 → llguidance-1.2.0}/json_stats/jstats.sh +0 -0
  55. {llguidance-1.1.1 → llguidance-1.2.0}/json_stats/scripts/split-stats.sh +0 -0
  56. {llguidance-1.1.1 → llguidance-1.2.0}/json_stats/scripts/split_plot.py +0 -0
  57. {llguidance-1.1.1 → llguidance-1.2.0}/json_stats/src/json_stats.rs +0 -0
  58. {llguidance-1.1.1 → llguidance-1.2.0}/json_stats/src/lib.rs +0 -0
  59. {llguidance-1.1.1 → llguidance-1.2.0}/json_stats/src/stats.rs +0 -0
  60. {llguidance-1.1.1 → llguidance-1.2.0}/parser/LICENSE +0 -0
  61. {llguidance-1.1.1 → llguidance-1.2.0}/parser/README.md +0 -0
  62. {llguidance-1.1.1 → llguidance-1.2.0}/parser/build.rs +0 -0
  63. {llguidance-1.1.1 → llguidance-1.2.0}/parser/cbindgen.toml +0 -0
  64. {llguidance-1.1.1 → llguidance-1.2.0}/parser/grammars/character.json +0 -0
  65. {llguidance-1.1.1 → llguidance-1.2.0}/parser/grammars/json.json +0 -0
  66. {llguidance-1.1.1 → llguidance-1.2.0}/parser/src/constraint.rs +0 -0
  67. {llguidance-1.1.1 → llguidance-1.2.0}/parser/src/earley/from_guidance.rs +0 -0
  68. {llguidance-1.1.1 → llguidance-1.2.0}/parser/src/earley/grammar.rs +0 -0
  69. {llguidance-1.1.1 → llguidance-1.2.0}/parser/src/earley/lexer.rs +0 -0
  70. {llguidance-1.1.1 → llguidance-1.2.0}/parser/src/earley/lexerspec.rs +0 -0
  71. {llguidance-1.1.1 → llguidance-1.2.0}/parser/src/earley/mod.rs +0 -0
  72. {llguidance-1.1.1 → llguidance-1.2.0}/parser/src/earley/parser.rs +0 -0
  73. {llguidance-1.1.1 → llguidance-1.2.0}/parser/src/earley/perf.rs +0 -0
  74. {llguidance-1.1.1 → llguidance-1.2.0}/parser/src/earley/regexvec.rs +0 -0
  75. {llguidance-1.1.1 → llguidance-1.2.0}/parser/src/earley/slicer.rs +0 -0
  76. {llguidance-1.1.1 → llguidance-1.2.0}/parser/src/factory.rs +0 -0
  77. {llguidance-1.1.1 → llguidance-1.2.0}/parser/src/ffi.rs +0 -0
  78. {llguidance-1.1.1 → llguidance-1.2.0}/parser/src/ffi_par.rs +0 -0
  79. {llguidance-1.1.1 → llguidance-1.2.0}/parser/src/grammar_builder.rs +0 -0
  80. {llguidance-1.1.1 → llguidance-1.2.0}/parser/src/hashcons.rs +0 -0
  81. {llguidance-1.1.1 → llguidance-1.2.0}/parser/src/json/README.md +0 -0
  82. {llguidance-1.1.1 → llguidance-1.2.0}/parser/src/json/compiler.rs +0 -0
  83. {llguidance-1.1.1 → llguidance-1.2.0}/parser/src/json/context_ref.rs +0 -0
  84. {llguidance-1.1.1 → llguidance-1.2.0}/parser/src/json/context_simple/context.rs +0 -0
  85. {llguidance-1.1.1 → llguidance-1.2.0}/parser/src/json/context_simple/draft.rs +0 -0
  86. {llguidance-1.1.1 → llguidance-1.2.0}/parser/src/json/context_simple/mod.rs +0 -0
  87. {llguidance-1.1.1 → llguidance-1.2.0}/parser/src/json/formats.rs +0 -0
  88. {llguidance-1.1.1 → llguidance-1.2.0}/parser/src/json/mod.rs +0 -0
  89. {llguidance-1.1.1 → llguidance-1.2.0}/parser/src/json/numeric.rs +0 -0
  90. {llguidance-1.1.1 → llguidance-1.2.0}/parser/src/json/schema.rs +0 -0
  91. {llguidance-1.1.1 → llguidance-1.2.0}/parser/src/json/shared_context.rs +0 -0
  92. {llguidance-1.1.1 → llguidance-1.2.0}/parser/src/json_validation.rs +0 -0
  93. {llguidance-1.1.1 → llguidance-1.2.0}/parser/src/lark/README.md +0 -0
  94. {llguidance-1.1.1 → llguidance-1.2.0}/parser/src/lark/ast.rs +0 -0
  95. {llguidance-1.1.1 → llguidance-1.2.0}/parser/src/lark/common.rs +0 -0
  96. {llguidance-1.1.1 → llguidance-1.2.0}/parser/src/lark/compiler.rs +0 -0
  97. {llguidance-1.1.1 → llguidance-1.2.0}/parser/src/lark/mod.rs +0 -0
  98. {llguidance-1.1.1 → llguidance-1.2.0}/parser/src/lark/parser.rs +0 -0
  99. {llguidance-1.1.1 → llguidance-1.2.0}/parser/src/lib.rs +0 -0
  100. {llguidance-1.1.1 → llguidance-1.2.0}/parser/src/logging.rs +0 -0
  101. {llguidance-1.1.1 → llguidance-1.2.0}/parser/src/matcher.rs +0 -0
  102. {llguidance-1.1.1 → llguidance-1.2.0}/parser/src/output.rs +0 -0
  103. {llguidance-1.1.1 → llguidance-1.2.0}/parser/src/regex_rewrite.rs +0 -0
  104. {llguidance-1.1.1 → llguidance-1.2.0}/parser/src/stop_controller.rs +0 -0
  105. {llguidance-1.1.1 → llguidance-1.2.0}/parser/src/substring.rs +0 -0
  106. {llguidance-1.1.1 → llguidance-1.2.0}/parser/src/tokenizer_json.rs +0 -0
  107. {llguidance-1.1.1 → llguidance-1.2.0}/plan.md +0 -0
  108. {llguidance-1.1.1 → llguidance-1.2.0}/python/llguidance/__init__.py +0 -0
  109. {llguidance-1.1.1 → llguidance-1.2.0}/python/llguidance/_grammar_from.py +0 -0
  110. {llguidance-1.1.1 → llguidance-1.2.0}/python/llguidance/_struct_tag.py +0 -0
  111. {llguidance-1.1.1 → llguidance-1.2.0}/python/llguidance/_tokenizer.py +0 -0
  112. {llguidance-1.1.1 → llguidance-1.2.0}/python/llguidance/_util.py +0 -0
  113. {llguidance-1.1.1 → llguidance-1.2.0}/python/llguidance/cli.py +0 -0
  114. {llguidance-1.1.1 → llguidance-1.2.0}/python/llguidance/gbnf_to_lark.py +0 -0
  115. {llguidance-1.1.1 → llguidance-1.2.0}/python/llguidance/hf.py +0 -0
  116. {llguidance-1.1.1 → llguidance-1.2.0}/python/llguidance/llamacpp.py +0 -0
  117. {llguidance-1.1.1 → llguidance-1.2.0}/python/llguidance/mlx.py +0 -0
  118. {llguidance-1.1.1 → llguidance-1.2.0}/python/llguidance/py.typed +0 -0
  119. {llguidance-1.1.1 → llguidance-1.2.0}/python/llguidance/tiktoken.py +0 -0
  120. {llguidance-1.1.1 → llguidance-1.2.0}/python/mypy.ini +0 -0
  121. {llguidance-1.1.1 → llguidance-1.2.0}/python/torch_tests/__init__.py +0 -0
  122. {llguidance-1.1.1 → llguidance-1.2.0}/python/torch_tests/test_bitmask.py +0 -0
  123. {llguidance-1.1.1 → llguidance-1.2.0}/python/torch_tests/test_hf.py +0 -0
  124. {llguidance-1.1.1 → llguidance-1.2.0}/python/torch_tests/test_llamacpp.py +0 -0
  125. {llguidance-1.1.1 → llguidance-1.2.0}/python/torch_tests/test_tiktoken.py +0 -0
  126. {llguidance-1.1.1 → llguidance-1.2.0}/python_ext/src/lib.rs +0 -0
  127. {llguidance-1.1.1 → llguidance-1.2.0}/python_ext/src/llamatokenizer.rs +0 -0
  128. {llguidance-1.1.1 → llguidance-1.2.0}/python_ext/src/llinterpreter.rs +0 -0
  129. {llguidance-1.1.1 → llguidance-1.2.0}/python_ext/src/py.rs +0 -0
  130. {llguidance-1.1.1 → llguidance-1.2.0}/python_ext/src/pyjson.rs +0 -0
  131. {llguidance-1.1.1 → llguidance-1.2.0}/sample_parser/Cargo.toml +0 -0
  132. {llguidance-1.1.1 → llguidance-1.2.0}/sample_parser/README.md +0 -0
  133. {llguidance-1.1.1 → llguidance-1.2.0}/sample_parser/cli.sh +0 -0
  134. {llguidance-1.1.1 → llguidance-1.2.0}/sample_parser/data/blog.sample.json +0 -0
  135. {llguidance-1.1.1 → llguidance-1.2.0}/sample_parser/data/blog.schema.json +0 -0
  136. {llguidance-1.1.1 → llguidance-1.2.0}/sample_parser/data/blog.schema.ll.json +0 -0
  137. {llguidance-1.1.1 → llguidance-1.2.0}/sample_parser/data/from-llama.cpp/README.md +0 -0
  138. {llguidance-1.1.1 → llguidance-1.2.0}/sample_parser/data/from-llama.cpp/arithmetic.gbnf +0 -0
  139. {llguidance-1.1.1 → llguidance-1.2.0}/sample_parser/data/from-llama.cpp/c.gbnf +0 -0
  140. {llguidance-1.1.1 → llguidance-1.2.0}/sample_parser/data/from-llama.cpp/chess.gbnf +0 -0
  141. {llguidance-1.1.1 → llguidance-1.2.0}/sample_parser/data/from-llama.cpp/english.gbnf +0 -0
  142. {llguidance-1.1.1 → llguidance-1.2.0}/sample_parser/data/from-llama.cpp/japanese.gbnf +0 -0
  143. {llguidance-1.1.1 → llguidance-1.2.0}/sample_parser/data/from-llama.cpp/json.gbnf +0 -0
  144. {llguidance-1.1.1 → llguidance-1.2.0}/sample_parser/data/from-llama.cpp/json_arr.gbnf +0 -0
  145. {llguidance-1.1.1 → llguidance-1.2.0}/sample_parser/data/from-llama.cpp/list.gbnf +0 -0
  146. {llguidance-1.1.1 → llguidance-1.2.0}/sample_parser/data/from-llama.cpp/vllm-sql.gbnf +0 -0
  147. {llguidance-1.1.1 → llguidance-1.2.0}/sample_parser/data/lark.lark +0 -0
  148. {llguidance-1.1.1 → llguidance-1.2.0}/sample_parser/data/rfc.lark +0 -0
  149. {llguidance-1.1.1 → llguidance-1.2.0}/sample_parser/data/rfc.xml +0 -0
  150. {llguidance-1.1.1 → llguidance-1.2.0}/sample_parser/data/ulysses.md +0 -0
  151. {llguidance-1.1.1 → llguidance-1.2.0}/sample_parser/gtest.sh +0 -0
  152. {llguidance-1.1.1 → llguidance-1.2.0}/sample_parser/lark.sh +0 -0
  153. {llguidance-1.1.1 → llguidance-1.2.0}/sample_parser/run.sh +0 -0
  154. {llguidance-1.1.1 → llguidance-1.2.0}/sample_parser/src/lib.rs +0 -0
  155. {llguidance-1.1.1 → llguidance-1.2.0}/sample_parser/src/minimal.rs +0 -0
  156. {llguidance-1.1.1 → llguidance-1.2.0}/sample_parser/src/sample_parser.rs +0 -0
  157. {llguidance-1.1.1 → llguidance-1.2.0}/sample_parser/tests/test_json_objects.rs +0 -0
  158. {llguidance-1.1.1 → llguidance-1.2.0}/sample_parser/tests/test_ll.rs +0 -0
  159. {llguidance-1.1.1 → llguidance-1.2.0}/sample_parser/tests/test_raw_parser.rs +0 -0
  160. {llguidance-1.1.1 → llguidance-1.2.0}/sample_parser/tests/test_stop.rs +0 -0
  161. {llguidance-1.1.1 → llguidance-1.2.0}/scripts/annotate_asm.js +0 -0
  162. {llguidance-1.1.1 → llguidance-1.2.0}/scripts/cbindgen.sh +0 -0
  163. {llguidance-1.1.1 → llguidance-1.2.0}/scripts/checklinks.py +0 -0
  164. {llguidance-1.1.1 → llguidance-1.2.0}/scripts/checklinks.sh +0 -0
  165. {llguidance-1.1.1 → llguidance-1.2.0}/scripts/ci-publish.py +0 -0
  166. {llguidance-1.1.1 → llguidance-1.2.0}/scripts/disasm.sh +0 -0
  167. {llguidance-1.1.1 → llguidance-1.2.0}/scripts/gbnf_to_lark.py +0 -0
  168. {llguidance-1.1.1 → llguidance-1.2.0}/scripts/gen-testcase.py +0 -0
  169. {llguidance-1.1.1 → llguidance-1.2.0}/scripts/git-version.sh +0 -0
  170. {llguidance-1.1.1 → llguidance-1.2.0}/scripts/install-deps.sh +0 -0
  171. {llguidance-1.1.1 → llguidance-1.2.0}/scripts/jsonschema-stats.js +0 -0
  172. {llguidance-1.1.1 → llguidance-1.2.0}/scripts/remote-guidance-test.sh +0 -0
  173. {llguidance-1.1.1 → llguidance-1.2.0}/scripts/rust-size.js +0 -0
  174. {llguidance-1.1.1 → llguidance-1.2.0}/scripts/rust_size.py +0 -0
  175. {llguidance-1.1.1 → llguidance-1.2.0}/scripts/test-guidance.sh +0 -0
  176. {llguidance-1.1.1 → llguidance-1.2.0}/scripts/tokenizer_test.py +0 -0
  177. {llguidance-1.1.1 → llguidance-1.2.0}/scripts/update-git.py +0 -0
  178. {llguidance-1.1.1 → llguidance-1.2.0}/toktrie/LICENSE +0 -0
  179. {llguidance-1.1.1 → llguidance-1.2.0}/toktrie/README.md +0 -0
  180. {llguidance-1.1.1 → llguidance-1.2.0}/toktrie/src/bytes.rs +0 -0
  181. {llguidance-1.1.1 → llguidance-1.2.0}/toktrie/src/lib.rs +0 -0
  182. {llguidance-1.1.1 → llguidance-1.2.0}/toktrie/src/recognizer.rs +0 -0
  183. {llguidance-1.1.1 → llguidance-1.2.0}/toktrie/src/rng.rs +0 -0
  184. {llguidance-1.1.1 → llguidance-1.2.0}/toktrie/src/svob.rs +0 -0
  185. {llguidance-1.1.1 → llguidance-1.2.0}/toktrie/src/tokenv.rs +0 -0
  186. {llguidance-1.1.1 → llguidance-1.2.0}/toktrie/src/toktree.rs +0 -0
  187. {llguidance-1.1.1 → llguidance-1.2.0}/toktrie/tests/test_svob.rs +0 -0
  188. {llguidance-1.1.1 → llguidance-1.2.0}/toktrie_hf_downloader/LICENSE +0 -0
  189. {llguidance-1.1.1 → llguidance-1.2.0}/toktrie_hf_downloader/src/lib.rs +0 -0
  190. {llguidance-1.1.1 → llguidance-1.2.0}/toktrie_hf_tokenizers/LICENSE +0 -0
  191. {llguidance-1.1.1 → llguidance-1.2.0}/toktrie_hf_tokenizers/src/lib.rs +0 -0
  192. {llguidance-1.1.1 → llguidance-1.2.0}/toktrie_tiktoken/LICENSE +0 -0
  193. {llguidance-1.1.1 → llguidance-1.2.0}/toktrie_tiktoken/src/lib.rs +0 -0
@@ -0,0 +1,62 @@
1
+ name: Code Coverage
2
+ permissions:
3
+ contents: read
4
+
5
+
6
+ on:
7
+ pull_request:
8
+ push:
9
+ branches: [ "main" ]
10
+ workflow_dispatch:
11
+ inputs:
12
+ commit_id:
13
+ description: 'Branch or Commit ID (optional)'
14
+ required: false
15
+ type: string
16
+
17
+
18
+ env:
19
+ CARGO_TERM_COLOR: always
20
+ RUSTFLAGS: "-Cinstrument-coverage"
21
+ LLVM_PROFILE_FILE: "llg-%p-%m.profraw"
22
+
23
+
24
+ jobs:
25
+ code-cov:
26
+ runs-on: ubuntu-latest
27
+
28
+ steps:
29
+ - name: Checkout repo at ${{ github.event_name == 'workflow_dispatch' && inputs.commit_id || github.sha }}
30
+ uses: actions/checkout@v4
31
+ with:
32
+ ref: ${{ github.event_name == 'workflow_dispatch' && inputs.commit_id || github.sha }}
33
+
34
+ - name: Update toolchain
35
+ run: rustup component add llvm-tools
36
+
37
+ - name: Install grcov
38
+ run: cargo install grcov
39
+
40
+ - name: Build everything
41
+ run: cargo build
42
+
43
+ - name: Run tests
44
+ run: cargo test
45
+
46
+ - name: Check environment
47
+ run: |
48
+ echo "CARGO_TERM_COLOR: $CARGO_TERM_COLOR"
49
+ echo "RUSTFLAGS: $RUSTFLAGS"
50
+ echo "LLVM_PROFILE_FILE: $LLVM_PROFILE_FILE"
51
+
52
+ - name: Generate coverage report
53
+ run: |
54
+ grcov . -s . --binary-path target/debug/ -t html --branch --ignore-not-existing -o target/debug/coverage/
55
+
56
+ - name: Check output
57
+ run: ls target/debug/coverage/
58
+
59
+ - uses: actions/upload-artifact@v4
60
+ with:
61
+ name: coverage-report
62
+ path: target/debug/coverage/
@@ -4,109 +4,121 @@ All notable changes to this project will be documented in this file. Dates are d
4
4
 
5
5
  If a release doesn't introduce any interesting changes (build fixes etc.), it's skipped.
6
6
 
7
- #### [1.1.1](https://github.com/guidance-ai/llguidance/compare/v1.1.0...1.1.1) 2025-07-23
7
+ #### [v1.1.3](https://github.com/guidance-ai/llguidance/compare/v1.1.2...v1.1.3) 2025-08-12
8
+
9
+ - support multithreaded compute bitmask for speculative decoding [`#225`](https://github.com/guidance-ai/llguidance/pull/225)
10
+ - thank you [@ZonePG](https://github.com/ZonePG)!
11
+ - `force_lexeme_end` -> `try_lexeme_end` in lark lexer when out of input [`#229`](https://github.com/guidance-ai/llguidance/pull/229); fixes [`#228`](https://github.com/guidance-ai/llguidance/issues/228)
12
+ - more JSON test coverage
13
+
14
+ #### [v1.1.2](https://github.com/guidance-ai/llguidance/compare/v1.1.1...v1.1.2) 2025-08-08
15
+
16
+ - add flag in ParserLimits to disable verbose errors [`#227`](https://github.com/guidance-ai/llguidance/pull/227)
17
+ - new tests and cleanups
18
+
19
+ #### [v1.1.1](https://github.com/guidance-ai/llguidance/compare/v1.1.0...v1.1.1) 2025-07-23
8
20
 
9
21
  - prevent error state when calling `try_consume_tokens` after parser is stopped [`#213`](https://github.com/guidance-ai/llguidance/pull/213); fixes [`#211`](https://github.com/guidance-ai/llguidance/issues/211)
10
22
  - set parser stop condition in `try_consume_tokens` even when some tokens are rejected [`#212`](https://github.com/guidance-ai/llguidance/pull/212)
11
23
 
12
- #### [1.1.0](https://github.com/guidance-ai/llguidance/compare/v1.0.1...1.1.0) 2025-07-18
24
+ #### [v1.1.0](https://github.com/guidance-ai/llguidance/compare/v1.0.1...v1.1.0) 2025-07-18
13
25
 
14
26
  - disable hf tokenizer truncation and padding [`#205`](https://github.com/guidance-ai/llguidance/pull/205); fixes [`#1322`](https://github.com/guidance-ai/guidance/issues/1322)
15
27
  - llama_cpp tokenizers: infer added tokens starting/ending with < and > to be special tokens [`#202`](https://github.com/guidance-ai/llguidance/pull/202)
16
28
  - add lark syntax for "any token" and negation of token ranges [`#201`](https://github.com/guidance-ai/llguidance/pull/201)
17
29
  - add de-recursion cook book to docs [`#199`](https://github.com/guidance-ai/llguidance/pull/199)
18
30
 
19
- #### [1.0.1](https://github.com/guidance-ai/llguidance/compare/v1.0.0...1.0.1) 2025-07-03
31
+ #### [v1.0.1](https://github.com/guidance-ai/llguidance/compare/v1.0.0...v1.0.1) 2025-07-03
20
32
 
21
33
  - fix: tokenizers normalizers sequence api changed [`#195`](https://github.com/guidance-ai/llguidance/pull/195)
22
34
  - Strip debug info from the wheels [`#194`](https://github.com/guidance-ai/llguidance/pull/194)
23
35
 
24
36
  Thank you @ammar-elsabe and @Ahajha!
25
37
 
26
- #### [1.0.0](https://github.com/guidance-ai/llguidance/compare/v0.7.30...1.0.0) 2025-06-23
38
+ #### [v1.0.0](https://github.com/guidance-ai/llguidance/compare/v0.7.30...v1.0.0) 2025-06-23
27
39
 
28
40
  This is identical to `0.7.30`, but indicates intended stability and from now on we'll try to follow semver.
29
41
 
30
- #### [0.7.30](https://github.com/guidance-ai/llguidance/compare/v0.7.29...0.7.30) 2025-06-23
42
+ #### [v0.7.30](https://github.com/guidance-ai/llguidance/compare/v0.7.29...v0.7.30) 2025-06-23
31
43
 
32
44
  - parametric grammars [`#192`](https://github.com/guidance-ai/llguidance/pull/192)
33
45
  - allow for tokens up to ~2k bytes; fixes #188 [`#188`](https://github.com/guidance-ai/llguidance/issues/188)
34
46
 
35
- #### [0.7.29](https://github.com/guidance-ai/llguidance/compare/v0.7.28...0.7.29) 2025-06-06
47
+ #### [v0.7.29](https://github.com/guidance-ai/llguidance/compare/v0.7.28...v0.7.29) 2025-06-06
36
48
 
37
49
  - cargo fmt
38
50
 
39
- #### [0.7.28](https://github.com/guidance-ai/llguidance/compare/v0.7.27...0.7.28) 2025-06-06
51
+ #### [v0.7.28](https://github.com/guidance-ai/llguidance/compare/v0.7.27...v0.7.28) 2025-06-06
40
52
 
41
53
  - fix lexer_stack=... panic with numeric tokens [`4e91b0f`](https://github.com/guidance-ai/llguidance/commit/4e91b0fa0c03572a5fc221ac0e0b05035af9dcfa)
42
54
 
43
- #### [0.7.27](https://github.com/guidance-ai/llguidance/compare/v0.7.26...0.7.27) 2025-06-04
55
+ #### [v0.7.27](https://github.com/guidance-ai/llguidance/compare/v0.7.26...v0.7.27) 2025-06-04
44
56
 
45
57
  - add toktrie_tiktoken and llguidance.tiktoken.lltokenizer_from_encoding [`#154`](https://github.com/guidance-ai/llguidance/issues/154)
46
58
  - implement clone on StopController [`#185`](https://github.com/guidance-ai/llguidance/issues/185)
47
59
 
48
- #### [0.7.26](https://github.com/guidance-ai/llguidance/compare/v0.7.25...0.7.26) 2025-05-30
60
+ #### [v0.7.26](https://github.com/guidance-ai/llguidance/compare/v0.7.25...v0.7.26) 2025-05-30
49
61
 
50
62
  - add support for & and ~ in lark regexes [`96fcee3`](https://github.com/guidance-ai/llguidance/commit/96fcee373697b57bead94d1bc06c17cf1c6134e4)
51
63
  - dump grammar in errors in LLInterpreter [`#183`](https://github.com/guidance-ai/llguidance/pull/183)
52
64
  - don't check lexer bytes invariant when we cannot rollback [`ec22083`](https://github.com/guidance-ai/llguidance/commit/ec220837051513a70177974ca389b7bf387455f1)
53
65
 
54
66
 
55
- #### [0.7.25](https://github.com/guidance-ai/llguidance/compare/v0.7.24...0.7.25) 2025-05-28
67
+ #### [v0.7.25](https://github.com/guidance-ai/llguidance/compare/v0.7.24...v0.7.25) 2025-05-28
56
68
 
57
69
  - add parse_special=False to tokenize_str/bytes() in python [`#181`](https://github.com/guidance-ai/llguidance/pull/181)
58
70
 
59
- #### [0.7.24](https://github.com/guidance-ai/llguidance/compare/v0.7.23...0.7.24) 2025-05-23
71
+ #### [v0.7.24](https://github.com/guidance-ai/llguidance/compare/v0.7.23...v0.7.24) 2025-05-23
60
72
 
61
73
  - add the sentinel token hack, fixes #180 [`#180`](https://github.com/guidance-ai/llguidance/issues/180)
62
74
 
63
- #### [0.7.23](https://github.com/guidance-ai/llguidance/compare/v0.7.22...0.7.23) 2025-05-22
75
+ #### [v0.7.23](https://github.com/guidance-ai/llguidance/compare/v0.7.22...v0.7.23) 2025-05-22
64
76
 
65
77
  - native llama.cpp tokenizer support [`#179`](https://github.com/guidance-ai/llguidance/pull/179)
66
78
  - improve special token detection in HF tokenizers [`6cae393`](https://github.com/guidance-ai/llguidance/commit/6cae393b9c04fe67621615ff22b46beab512d069)
67
79
 
68
- #### [0.7.22](https://github.com/guidance-ai/llguidance/compare/v0.7.21...0.7.22) 2025-05-21
80
+ #### [v0.7.22](https://github.com/guidance-ai/llguidance/compare/v0.7.21...v0.7.22) 2025-05-21
69
81
 
70
82
  - Keep EOS token bytes in `TokenizerWrapper` [`#178`](https://github.com/guidance-ai/llguidance/pull/178)
71
83
  - Stop using prefix/sentinel strings for `TokenizerWrapper` [`#175`](https://github.com/guidance-ai/llguidance/pull/175)
72
84
  - avoid taking poisoned locks, see [`#174`](https://github.com/guidance-ai/llguidance/issues/174) [`d41aa9a`](https://github.com/guidance-ai/llguidance/commit/d41aa9a4427967708a951506b2bc0e395871b6c8); thanks [@g-eoj](https://github.com/g-eoj)
73
85
 
74
- #### [0.7.21](https://github.com/guidance-ai/llguidance/compare/v0.7.20...0.7.21) 2025-05-20
86
+ #### [v0.7.21](https://github.com/guidance-ai/llguidance/compare/v0.7.20...v0.7.21) 2025-05-20
75
87
 
76
88
  - include parser state in errors [`82e34da`](https://github.com/guidance-ai/llguidance/commit/82e34da704d22f04979d8cbc54a0ac00885a277d)
77
89
  - tighten email format in JSON schema [`7454ea9`](https://github.com/guidance-ai/llguidance/commit/7454ea9df958f8bcc42e6bb986d6de397de65b3e)
78
90
 
79
- #### [0.7.20](https://github.com/guidance-ai/llguidance/compare/v0.7.19...0.7.20) 2025-05-15
91
+ #### [v0.7.20](https://github.com/guidance-ai/llguidance/compare/v0.7.19...v0.7.20) 2025-05-15
80
92
 
81
93
  - use fancy-regex instead of onig as tokenizers regex library [`#172`](https://github.com/guidance-ai/llguidance/pull/172)
82
94
  - fixes compilation on GCC 15, thanks [@Slowki](https://github.com/Slowki)
83
95
  - msrv 1.80 support (incl. derivre bump) [`c89e386`](https://github.com/guidance-ai/llguidance/commit/c89e386685cd911a89fd47df225de88f88c10883), thank you [@nteodosio](https://github.com/nteodosio) for initial [PR](https://github.com/guidance-ai/llguidance/pull/170)!
84
96
 
85
- #### [0.7.19](https://github.com/guidance-ai/llguidance/compare/v0.7.18...0.7.19) 2025-04-24
97
+ #### [v0.7.19](https://github.com/guidance-ai/llguidance/compare/v0.7.18...v0.7.19) 2025-04-24
86
98
 
87
99
  - fix a numeric token bug [`1f59edf`](https://github.com/guidance-ai/llguidance/commit/1f59edfc49b44cfba74b2380f34874a0778d9441)
88
100
 
89
- #### [0.7.18](https://github.com/guidance-ai/llguidance/compare/v0.7.17...0.7.18) 2025-04-22
101
+ #### [v0.7.18](https://github.com/guidance-ai/llguidance/compare/v0.7.17...v0.7.18) 2025-04-22
90
102
 
91
103
  - apply x-guidance also in %json{} [`2627891`](https://github.com/guidance-ai/llguidance/commit/2627891c72c7e38062cd3e052f1de146d2e21635)
92
104
  - more sensible llg_validate_grammar() signature [`41928c0`](https://github.com/guidance-ai/llguidance/commit/41928c07298e69e3c8adc4a3c1f43ef9b1cc1c6b)
93
105
 
94
- #### [0.7.17](https://github.com/guidance-ai/llguidance/compare/v0.7.16...0.7.17) 2025-04-22
106
+ #### [v0.7.17](https://github.com/guidance-ai/llguidance/compare/v0.7.16...v0.7.17) 2025-04-22
95
107
 
96
108
  - support for min/maxProperties in JSON Schema [`#168`](https://github.com/guidance-ai/llguidance/issues/168)
97
109
  - give priority to <[123]> over "foo" in grammar [`3e9f3b5`](https://github.com/guidance-ai/llguidance/commit/3e9f3b5e8c1cac92daab6e9709f01ebccc20342b)
98
110
 
99
- #### [0.7.16](https://github.com/guidance-ai/llguidance/compare/v0.7.15...0.7.16) 2025-04-17
111
+ #### [v0.7.16](https://github.com/guidance-ai/llguidance/compare/v0.7.15...v0.7.16) 2025-04-17
100
112
 
101
113
  - fix special token tokenization [`ae7870f`](https://github.com/guidance-ai/llguidance/commit/ae7870f05ca0de68599088607ba742b7071f92ad)
102
114
 
103
- #### [0.7.15](https://github.com/guidance-ai/llguidance/compare/v0.7.14...0.7.15) 2025-04-16
115
+ #### [v0.7.15](https://github.com/guidance-ai/llguidance/compare/v0.7.14...v0.7.15) 2025-04-16
104
116
 
105
117
  - support for patternProperties in JSON schema [`#167`](https://github.com/guidance-ai/llguidance/pull/167)
106
118
  - add lenient option to JSON schemas [`#163`](https://github.com/guidance-ai/llguidance/pull/163) [`#136`](https://github.com/guidance-ai/llguidance/issues/136)
107
119
  - Add llg_validate_grammar() in C FFI [`e5c21cf`](https://github.com/guidance-ai/llguidance/commit/e5c21cf480a17e6b310e46b24b272576cfd9c4c6)
108
120
 
109
- #### [0.7.14](https://github.com/guidance-ai/llguidance/compare/v0.7.13...0.7.14) 2025-04-11
121
+ #### [v0.7.14](https://github.com/guidance-ai/llguidance/compare/v0.7.13...v0.7.14) 2025-04-11
110
122
 
111
123
  - support %lark { ... } syntax for nested grammars [`#157`](https://github.com/guidance-ai/llguidance/pull/157)
112
124
  - treat \d and \w in json schema as ASCII; fix ^$ anchors [`#158`](https://github.com/guidance-ai/llguidance/issues/158)
@@ -115,19 +127,19 @@ This is identical to `0.7.30`, but indicates intended stability and from now on
115
127
  - expose regex_to_lark() in Rust and Python; add \d\w\s replacement [`78fb32f`](https://github.com/guidance-ai/llguidance/commit/78fb32fe2745d30ca94a62b00e5a7299750d80b0)
116
128
  - fix usage of / vs \* in python signatures [`ca73c2a`](https://github.com/guidance-ai/llguidance/commit/ca73c2abd44e75d569230b942f53c72b052ed2ab)
117
129
 
118
- #### [0.7.13](https://github.com/guidance-ai/llguidance/compare/v0.7.12...0.7.13) 2025-04-05
130
+ #### [v0.7.13](https://github.com/guidance-ai/llguidance/compare/v0.7.12...v0.7.13) 2025-04-05
119
131
 
120
132
  - expose LLParserLimits in Python API [`598dc8f`](https://github.com/guidance-ai/llguidance/commit/598dc8f37f69f51244e54d9885445abf02a515a7)
121
133
  - pre-compute lexer states for particularly large regexes (can be disabled in ParserLimits)
122
134
 
123
- #### [0.7.12](https://github.com/guidance-ai/llguidance/compare/v0.7.11...0.7.12) 2025-04-04
135
+ #### [v0.7.12](https://github.com/guidance-ai/llguidance/compare/v0.7.11...v0.7.12) 2025-04-04
124
136
 
125
137
  - performance optimizations
126
138
  - use factory in C FFI (otherwise slicer was not used)
127
139
  - add some null checks and safety comments in C FFI
128
140
  - implement subgrammar lexeme class merging; fixes [`#113`](https://github.com/guidance-ai/llguidance/issues/113)
129
141
 
130
- #### [0.7.11](https://github.com/guidance-ai/llguidance/compare/v0.7.10...0.7.11) 2025-03-27
142
+ #### [v0.7.11](https://github.com/guidance-ai/llguidance/compare/v0.7.10...v0.7.11) 2025-03-27
131
143
 
132
144
  - add StructTag python API; fixes [`#146`](https://github.com/guidance-ai/llguidance/issues/146)
133
145
  - fix handling of AddedToken.special (gemma tokenizer, fixes [`#147`](https://github.com/guidance-ai/llguidance/issues/147))
@@ -1241,7 +1241,7 @@ checksum = "241eaef5fd12c88705a01fc1066c48c4b36e0dd4377dcdc7ec3942cea7a69956"
1241
1241
 
1242
1242
  [[package]]
1243
1243
  name = "llguidance"
1244
- version = "1.1.1"
1244
+ version = "1.2.0"
1245
1245
  dependencies = [
1246
1246
  "anyhow",
1247
1247
  "derivre",
@@ -1260,7 +1260,7 @@ dependencies = [
1260
1260
 
1261
1261
  [[package]]
1262
1262
  name = "llguidance_py"
1263
- version = "1.1.1"
1263
+ version = "1.2.0"
1264
1264
  dependencies = [
1265
1265
  "anyhow",
1266
1266
  "bytemuck",
@@ -2478,7 +2478,7 @@ dependencies = [
2478
2478
 
2479
2479
  [[package]]
2480
2480
  name = "toktrie"
2481
- version = "1.1.1"
2481
+ version = "1.2.0"
2482
2482
  dependencies = [
2483
2483
  "anyhow",
2484
2484
  "bytemuck",
@@ -2489,7 +2489,7 @@ dependencies = [
2489
2489
 
2490
2490
  [[package]]
2491
2491
  name = "toktrie_hf_downloader"
2492
- version = "1.1.1"
2492
+ version = "1.2.0"
2493
2493
  dependencies = [
2494
2494
  "anyhow",
2495
2495
  "hf-hub",
@@ -2500,7 +2500,7 @@ dependencies = [
2500
2500
 
2501
2501
  [[package]]
2502
2502
  name = "toktrie_hf_tokenizers"
2503
- version = "1.1.1"
2503
+ version = "1.2.0"
2504
2504
  dependencies = [
2505
2505
  "anyhow",
2506
2506
  "log",
@@ -2512,7 +2512,7 @@ dependencies = [
2512
2512
 
2513
2513
  [[package]]
2514
2514
  name = "toktrie_tiktoken"
2515
- version = "1.1.1"
2515
+ version = "1.2.0"
2516
2516
  dependencies = [
2517
2517
  "anyhow",
2518
2518
  "log",
@@ -1,10 +1,10 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: llguidance
3
- Version: 1.1.1
3
+ Version: 1.2.0
4
4
  License-File: LICENSE
5
5
  Summary: Bindings for the Low-level Guidance (llguidance) Rust library for use within Guidance
6
6
  Author: Michal Moskal
7
- License: MIT
7
+ License-Expression: MIT
8
8
  Requires-Python: >=3.9
9
9
  Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
10
10
  Project-URL: repository, https://github.com/microsoft/llguidance
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "llguidance"
3
- version = "1.1.1"
3
+ version = "1.2.0"
4
4
  edition = "2021"
5
5
  license = "MIT"
6
6
  description = "Super-fast Structured Outputs"
@@ -78,6 +78,12 @@ typedef struct LlgParserLimits {
78
78
  * Default: true
79
79
  */
80
80
  bool precompute_large_lexemes;
81
+ /**
82
+ * If true, include parser state (including tokens so far) and grammar in
83
+ * errors.
84
+ * Default: true
85
+ */
86
+ bool verbose_errors;
81
87
  } LlgParserLimits;
82
88
 
83
89
  typedef struct LlgConstraintInit {
@@ -258,6 +258,11 @@ pub struct ParserLimits {
258
258
  /// the time it takes to construct the lexer.
259
259
  /// Default: true
260
260
  pub precompute_large_lexemes: bool,
261
+
262
+ /// If true, include parser state (including tokens so far) and grammar in
263
+ /// errors.
264
+ /// Default: true
265
+ pub verbose_errors: bool,
261
266
  }
262
267
 
263
268
  impl Default for ParserLimits {
@@ -270,6 +275,7 @@ impl Default for ParserLimits {
270
275
  max_grammar_size: 500_000, // fhir schema => 200k
271
276
  step_max_items: 50_000, //
272
277
  precompute_large_lexemes: true,
278
+ verbose_errors: true,
273
279
  }
274
280
  }
275
281
  }
@@ -279,7 +279,7 @@ pub fn lex_lark(input: &str) -> Result<Vec<Lexeme>> {
279
279
  while idx <= input_bytes.len() {
280
280
  let mut b = b'\n';
281
281
  let res = if idx == input_bytes.len() {
282
- lexer.force_lexeme_end(state)
282
+ lexer.try_lexeme_end(state)
283
283
  } else {
284
284
  b = input_bytes[idx];
285
285
  lexer.advance(state, b, false)
@@ -24,7 +24,7 @@ pub fn mk_panic_error(info: &Box<dyn Any + Send>) -> String {
24
24
  let b = BACKTRACE.with(|b| b.take());
25
25
 
26
26
  if let Some(b) = b {
27
- format!("panic: {msg}\n{b}")
27
+ format!("panic: {msg}\n<backtrace>\n{b}\n</backtrace>")
28
28
  } else {
29
29
  format!("panic: {msg}")
30
30
  }
@@ -280,11 +280,15 @@ impl TokenParser {
280
280
  }
281
281
 
282
282
  pub fn augment_err(&self, e: impl Display) -> String {
283
- format!(
284
- "{e}\n<state>\n{}\n</state><grammar>\n{}\n</grammar>",
285
- self.dump_state(),
286
- self.dbg_grammar
287
- )
283
+ if self.limits.verbose_errors {
284
+ format!(
285
+ "{e}\n<state>\n{}\n</state><grammar>\n{}\n</grammar>",
286
+ self.dump_state(),
287
+ self.dbg_grammar
288
+ )
289
+ } else {
290
+ format!("{e}\n<non-verbose/>")
291
+ }
288
292
  }
289
293
 
290
294
  pub fn dump_state(&self) -> String {
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "llguidance"
3
- version = "1.1.1"
3
+ version = "1.2.0"
4
4
  description = "Bindings for the Low-level Guidance (llguidance) Rust library for use within Guidance"
5
5
  requires-python = ">=3.9"
6
6
  license = "MIT"
@@ -526,18 +526,49 @@ class LLExecutor:
526
526
  self,
527
527
  interpreters: List[Tuple[LLMatcher, int]],
528
528
  trg_pointer: int,
529
- one_mask_byte_size: int,
529
+ one_mask_bytes: int,
530
530
  trg_batch_size: int,
531
531
  ) -> None:
532
532
  """
533
533
  Compute the token mask directly into memory at the specified pointer.
534
534
  For each matcher, provide the index of the target mask.
535
- If index is K, the memory will be written at trg_pointer + K * one_mask_byte_size,
535
+ If index is K, the memory will be written at trg_pointer + K * one_mask_bytes,
536
536
  where K < trg_batch_size.
537
- Memory has to have size trg_batch_size * one_mask_byte_size.
537
+ Memory has to have size trg_batch_size * one_mask_bytes.
538
538
  Prefer to use fill_next_token_bitmask_par(), which wraps this.
539
539
  """
540
540
 
541
+ def unsafe_compute_mask_ptr_with_draft_token(
542
+ self,
543
+ interpreters: List[Tuple[LLMatcher, int, List[int]]],
544
+ trg_pointer: int,
545
+ one_mask_bytes: int,
546
+ trg_batch_size: int,
547
+ ) -> None:
548
+ """
549
+ Compute the token mask directly into memory at the specified pointer, including draft tokens.
550
+
551
+ This function extends unsafe_compute_mask_ptr() to handle draft tokens in speculative decoding.
552
+ For each matcher in the batch, it computes masks for both the current position and all draft tokens.
553
+
554
+ Args:
555
+ interpreters: List of tuples containing:
556
+ - LLMatcher: The matcher object for constrained generation
557
+ - int: Index K indicating the target mask position (K < trg_batch_size)
558
+ - List[int]: Draft tokens to be processed for speculative decoding
559
+ trg_pointer: Memory address where mask data will be written
560
+ one_mask_bytes: Size in bytes of a single token mask
561
+ trg_batch_size: Total batch size for memory allocation validation
562
+
563
+ Memory Layout:
564
+ - Main mask written at: trg_pointer + K * one_mask_bytes
565
+ - Draft token i mask written at: trg_pointer + (K + i + 1) * one_mask_bytes
566
+ - Total memory required: trg_batch_size * one_mask_bytes
567
+
568
+ The function processes each matcher's draft tokens sequentially, advancing the matcher state
569
+ for each valid token until encountering an invalid token or termination condition.
570
+ State rollback is performed to maintain matcher consistency.
571
+ """
541
572
 
542
573
  class JsonCompileOptions(TypedDict, total=False):
543
574
  # defaults to ","
@@ -565,6 +596,7 @@ class LLParserLimits:
565
596
  max_lexer_states: Optional[int] = None,
566
597
  max_grammar_size: Optional[int] = None,
567
598
  precompute_large_lexemes: Optional[bool] = None,
599
+ verbose_errors: Optional[bool] = None,
568
600
  ) -> None:
569
601
  """
570
602
  ParserLimits configuration for controlling parser and lexer resource usage.
@@ -597,6 +629,10 @@ class LLParserLimits:
597
629
  precompute_large_lexemes (Optional[bool]):
598
630
  Whether to run large regexes eagerly on the entire token trie during lexer build.
599
631
  Increases lexer construction time, but speeds up mask computation. Default: True.
632
+
633
+ verbose_errors (Optional[bool]):
634
+ If true, include parser state and grammar details in error messages.
635
+ Useful for debugging; may leak schema/state in logs. Default: True.
600
636
  """
601
637
 
602
638
  @property
@@ -627,6 +663,10 @@ class LLParserLimits:
627
663
  def precompute_large_lexemes(self) -> bool:
628
664
  """Precompute large regexes during lexer construction. Default: True"""
629
665
 
666
+ @property
667
+ def verbose_errors(self) -> bool:
668
+ """Include parser state and grammar in errors. Default: True"""
669
+
630
670
 
631
671
  def regex_to_lark(regex: str, use_ascii: str = "d") -> str:
632
672
  r"""
@@ -66,3 +66,17 @@ def fill_next_token_bitmask_par(executor: LLExecutor,
66
66
  batch, vocab = bitmask.shape
67
67
  assert bitmask.flags["C_CONTIGUOUS"], "Mask must be contiguous"
68
68
  executor.unsafe_compute_mask_ptr(matchers, bitmask.ctypes.data, vocab * 4, batch)
69
+
70
+
71
+ def fill_next_token_bitmask_par_with_draft_tokens(executor: LLExecutor,
72
+ matchers: List[Tuple[LLMatcher, int, List[int]]],
73
+ bitmask: NDArray[np.int32]) -> None:
74
+ """
75
+ Compute the token mask directly into the specified array.
76
+ For each matcher, provide the index of the target mask.
77
+ """
78
+ assert bitmask.dtype == np.int32, "Mask must be int32"
79
+ assert bitmask.ndim == 2, "Mask must be 2D"
80
+ batch, vocab = bitmask.shape
81
+ assert bitmask.flags["C_CONTIGUOUS"], "Mask must be contiguous"
82
+ executor.unsafe_compute_mask_ptr_with_draft_token(matchers, bitmask.ctypes.data, vocab * 4, batch)
@@ -66,3 +66,14 @@ def fill_next_token_bitmask_par(executor: LLExecutor,
66
66
  assert bitmask.is_contiguous(), "Mask must be contiguous"
67
67
  executor.unsafe_compute_mask_ptr(matchers, bitmask.data_ptr(), vocab * 4,
68
68
  batch)
69
+
70
+
71
+ def fill_next_token_bitmask_par_with_draft_tokens(executor: LLExecutor,
72
+ matchers: List[Tuple[LLMatcher, int, List[int]]],
73
+ bitmask: torch.Tensor) -> None:
74
+ assert bitmask.dtype == torch.int32, "Mask must be int32"
75
+ assert bitmask.is_cpu, "Mask must be on CPU"
76
+ assert bitmask.dim() == 2, "Mask must be 2D"
77
+ batch, vocab = bitmask.shape
78
+ assert bitmask.is_contiguous(), "Mask must be contiguous"
79
+ executor.unsafe_compute_mask_ptr_with_draft_token(matchers, bitmask.data_ptr(), vocab * 4, batch)