-
Notifications
You must be signed in to change notification settings - Fork 52
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
Is there any way to do actual things besides mathematical computation with silq? #30
Comments
Hey, Since real QC Hardware is rare and pretty sophisticated it will be difficult to interact with hardware. However, we could integrate something like a OpenQASM Transpiler to write code that emulates on Qiskit Metal like quantum emulators. Best regards |
What about something like a kernel API? Something that serves as a more platform independent interface to the hardware like how I can create a TCP connection by importing linux headers in my C code. |
Well, I am not sure but if Silq supports native dlang interop, then this will surely be possible. |
I'll treat this issue like an enhancement request for some sort of FFI. @Ktedon: The focus of Silq is expressing quantum computation in a high-level fashion. Best, |
Indeed, I think a compilation target to OpenQASM or similar low-level infrastructure would be a great milestone for reaching interaction with QC prototypes. (Or at least emulated ones). Regards |
Nevermind. This goes by #21 |
I'd be happy to try to implement a FFI to D, C, C++, and maybe some other high level language. I am unfamiliar with D but am familiar with Zig and C. Looking at the code base I can understand it quite well. That said, there should be some consensus on syntax and general approval before I begin doing so. Perhaps it looks a little something like: Also, do people like this idea, I mean a FFI? |
Yeah. An FFI would be a good part especially when we can experiment with new quantum paradigms such as polymorphic quantum states and so on. I also have quite some experience with C, C++ and D. Maybe we can take a reference on an API between D and LibFFI |
One more thing we should consider in terms of design is how we are going to handle the types between D and Silq. Naturally classical types would be used for calling and interacting with classical computer languages. But we would need to possibly add more classical types to be able to call all the appropriate functions. Additionally, we will need some sort of error handling in the case that a foreign function fails. |
Some other things to consider:
|
Special types that don't easily map to Silq types (e.g. |
Probably there should be a distinction between functions that have a memory safe interface and other functions. |
FFI support and any potential external dependencies it implies should be optional during the build. The bulk of the FFI implementation should be in a new git submodule. |
I think that the foreign file imports should be in the form of strings because file names can have spaces in them. We could also use pragma syntax instead of extern because it would be more flexible to extensions in the future. I wonder if it would be possible to create variables to represent global state that can be passed as a global state to any foreign function to modify it like this:
I believe this is what you were talking about when you were referring to additional parameters to refer to global state. This could be done lazily so that if we were call something like One more thing we should consider is how we are going to handle handles in C functions. I think we could unify against a parameter in a function. Since the function will only be one way the value will be passed into the function and then that value will be unified against the parameter in the function updating itself. That said, we would need extra unification syntax as an addition to the language. Could you clarify what you mean by unsafe and safe function interfaces? Do you just mean safe and unsafe function in general? |
Low-level functions that are intentionally designed to possibly be able to break type system invariants if called with bad arguments have an unsafe interface. Functions with a safe interface are intended to have well-defined behavior for all combinations of argument values. It's about what's written in some trusted specification, not about what the functions will actually do in practice (they may have bugs).
That fully depends on how you define those terms. |
That sounds like a pain. Perhaps we just force the developers to make smart decisions about calling functions with unsafe interfaces and for functions which return errors on execution like division which will fail if the denominator is 0. |
I am not really willing to completely give up on type safety without some sort of mitigation strategy that limits/localizes the potential for UB to be caused by errors in Silq code. |
You're right. I suppose I was feeling lazy last yesterday. What if all return values from foreign functions are wrapped in a "try" constructor. The user would be forced to handle every foreign function call as if there were going to be an error. |
Hello,
Please forgive my foolish title phrasing.
I am inquiring about what I must go through in order to build real world applications with silq (theoretically). Suppose I wanted to implement a library for controlling audio on a device. Hopefully it would both work on my laptop and any theoretical quantum computer supporting the syscalls. I don't see much in terms of a virtual machine with these implemented like with the JVM or anything. I don't know much about quantum computing or the technologies that silq is built upon but am interested to learn more.
Is it at all possible to interact with hardware instead doing computation in a very abstract way?
Sincerely, Walther Green
The text was updated successfully, but these errors were encountered: