Repository navigation
fix(python): grow buffers instead of failing and guard optional ops - #826
Open
Python11235 wants to merge 1 commit into
Open
Python11235 wants to merge 1 commit into
Python11235 wants to merge 1 commit into
Conversation
- Retry tokenize, text/image/audio embedding and audio feature preprocessing with a larger buffer when the C side returns -2 (buffer too small) instead of raising a generic error. - Raise a clear "rebuild with cactus build --python" error when an optional graph op is missing from the loaded library, instead of a bare AttributeError. - Handle empty inputs in the index helpers and bounds-check embedding sizes returned by cactus_index_get. - Validate dynamic_dims length against the input shape in Graph.input. - Resolve Tensor shape and dtype lazily, reuse the known shape and dtype for graph inputs, and skip the copy in set_input when the array already has the target dtype and layout. - Marshal PCM bytes with a single buffer copy instead of unpacking every byte into a ctypes array. Signed-off-by: Python/er <241503998+Python11235@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Hf1fEfGn1rnodpQdjope6c
This branch has not been deployed
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
Python binding fixes in
python/cactus/bindings/cactus.py:cactus_tokenize,cactus_embed,cactus_image_embed,cactus_audio_embedandcactus_preprocess_audio_featuresnow retry with a larger buffer when the C side returns-2(buffer too small). Before, they raised a generic error.-2means "buffer too small" in all five C implementations.RuntimeError("... rebuild with cactus build --python")instead of a bareAttributeError. Thegather→cactus_graph_gatherfallback still works.idsand empty embeddings are handled, and embedding sizes returned bycactus_index_getare bounds-checked.Graph.inputchecks thatdynamic_dimshas the same length asshape.Tensorshape and dtype are resolved lazily, graph inputs reuse the shape and dtype they were created with, andset_inputskips the copy when the array already has the target dtype and layout.Replaces #814, which failed the DCO check. This is the same change, squashed and signed off.
Testing
pytest tests/ --ignore=tests/test_model.py --ignore=tests/test_server_live.pygives the same results asmain(171 passed, no new failures). I ran it against a stub library on x86, because the kernels need ARM to build.gatherfallback, the concurrentcactus_completecalls and PCM marshaling: all pass.🤖 Generated with Claude Code
https://claude.ai/code/session_01Hf1fEfGn1rnodpQdjope6c