-
Notifications
You must be signed in to change notification settings - Fork 10
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
Make PyO3 bindings an optional feature #14
Conversation
8a8fa49
to
5b6e765
Compare
ab04e5b
to
15d9e19
Compare
5b6e765
to
1de92be
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note:: The last function
create_fsm_index_end_to_end
cannot be internalized right away as a pure Rust function because there is usage ofPyDict
within the function logic, but that should be easy enough to resolve. The main issue is that if we use the logic that we are using for the rest of the functions (wrapping the Python bindings around a*_internal
Rust version) we'd have to convert the hugestates_to_token_subsets
dictionary from RustHashMap
s toPyDict
wherein it could've been constructed asPyDict
in the first place, as it is being done right now. This would be a regression in terms of performance.
- Make a Rust version of
create_fsm_index_end_to_end
so that it's available in the pure Rust package without python bindings.
I'm fine moving forward with this and addressing the Rust-only version of states_to_token_subsets
in a follow-up.
We might want to wait until #15 is merged so that we can rebase this and then merge it.
The merge-base changed after approval.
347e191
to
c448997
Compare
0c1816e
to
3da8df6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good 👍
One small (but important thing) is to have the rlib in there as well, otherwise I think it can't be imported by rust projects:
crate-type = ["cdylib", "rlib"]
I also when running cargo build --features python-bindings
, I get a compile error:
...
"__Py_NoneStruct", referenced from:
pyo3_ffi::object::Py_None::hb5c6297611a670d5 in outlines_core_rs.ax4ei8tw6kqx8u3n4jsaoie49.rcgu.o
pyo3_ffi::object::Py_None::h0a3a434a6d719957 in libpyo3-f9af37ea37f46715.rlib[15](pyo3-f9af37ea37f46715.pyo3.a12b04b38ef4efd4-cgu.12.rcgu.o)
"__Py_TrueStruct", referenced from:
pyo3_ffi::boolobject::Py_True::h325d151b7e5600ac in libpyo3-f9af37ea37f46715.rlib[6](pyo3-f9af37ea37f46715.pyo3.a12b04b38ef4efd4-cgu.03.rcgu.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: could not compile `outlines-core-rs` (lib) due to 1 previous error
But I'm pretty sure this is something off on my system. So probably nothing that should block merging this PR.
dfbdfba
to
b8dfa3b
Compare
Added. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome 🚀
As titled,
This PR makes use of
cargo --features
flag to optionally compile the python bindings when required. Without the usage of--features python-bindings
, cargo will only compile the pure rust functions.Note:: The last function
create_fsm_index_end_to_end
cannot be internalized right away as a pure Rust function because there is usage ofPyDict
within the function logic, but that should be easy enough to resolve. The main issue is that if we use the logic that we are using for the rest of the functions (wrapping the Python bindings around a*_internal
Rust version) we'd have to convert the hugestates_to_token_subsets
dictionary from RustHashMap
s toPyDict
wherein it could've been constructed asPyDict
in the first place, as it is being done right now. This would be a regression in terms of performance.[ ] Make a Rust version ofCreate Rust-only index construction function #9create_fsm_index_end_to_end
so that it's available in the pure Rust package without python bindings.