A client python API for accessing LightSolver's capabilities
Project description
LightSolver Client
The LightSolver Client is a Python package designed to interface with the LightSolver Cloud Platform to facilitate solving problems on LightSolver's LPU (Laser Processing Unit) and dLPU (digital-LPU) solvers.
This package is designated for early access to features during the development process and serves as a prototype for future versions of the production LightSolver Client.
Features
- QUBO Problem Solving: The
solve_qubofunction accepts a QUBO problem, represented either as a 2D array (matrix) or an adjacency list, and returns the solution using the dLPU. - Synchronous and Asynchronous Operation: Users can choose between blocking (synchronous) and non-blocking (asynchronous) modes during problem solving.
- Fetching Account Details: Account information is available through this client. Includes: email, dLPU solve time remaining, dLPU variable count ("spin") limit and the user's expiration date.
- Flexible Installation: Compatible with both Windows and MacOS systems.
Solve QUBO
The solve_qubo function solves QUBO problems, either represented by a 2D array (matrix) or by an adjacency list, over the dLPU. For code samples, see the /tests directory.
Input Matrix Validity
- The matrix must be square.
- The matrix supports int or float cell values.
Return Value
A dictionary with the following fields:
- 'id': Unique identifier of the solution.
- 'solution': The solution as a Python list() of 1s and 0s.
- 'objval: The objective value of the solution.
- 'solverRunningTime': Time spent by the solver to calculate the problem.
- 'receivedTime': Timestamp when the request was received by the server.
Synchronous and Asynchronous Usage
- Synchronous Mode (Default): The
waitForSolutionflag is set to True by default. The function blocks operations until a result is received. - Asynchronous Mode: Set
waitForSolutionto False. The function returns immediately with a token object, allowing the script to continue while the server processes the QUBO problem.
Fetching Account Details
The get_account_details() function returns a python dictionary containing the following keys:
- 'dlpu_spin_limit': an int indicating the largest matrix size the user can send to the dlpu (dimensions of dlpu_spin_limit X dlpu_spin_limit).
- 'username': the username / email associated with this user. String.
- 'expiration_date: an Epoch timestamp indicating when the user expires. Int.
- 'dlpu_credit_seconds': solve time remaining for the user. Float.
Setting Up
Prerequisites
- Operating System: MacOS or Windows 11.
- Valid token for connecting to the LightSolver Cloud (provided separately).
- Python 3.10 or higher (Download Here).
- Select the appropriate MacOS/Windows version at the bottom.
- Note: for Windows installation, switch on the "Add to Path" option in the wizard.
- Highly Recommended: Use a virtual environment before installing laser-mind-client (Please see detailed action further below under the relevant OS).
Installation
Complete the installation on Windows or MacOS as described below. For further assistance with setup or connection issues, contact support@lightsolver.com.
Windows
-
Press the windows key, type "cmd", and select "Command Prompt".
-
Navigate to the root folder of the project where you plan to use the LightSolver Client:
cd <your project folder>
- (Recommended) Create and activate the virtual environment:
python -m venv .venv
.venv\Scripts\activate
- Install the laser-mind-client package:
pip install laser-mind-client
- (Recommended) Test using one of the provided test examples. Under the above project folder unzip "lightsolver_onboarding.zip."
cd lightsolver_onboarding
open test_solve_qubo_matrix.py file for edit
enter the provided TOKEN in line 6 (userToken = "<my_token>")
python ./tests/test_solve_qubo_matrix.py
MacOS
-
Open new terminal window.
-
Navigate to the root folder of the project where you plan to use the LightSolver Client:
cd <your project folder>
- (Recommended) Create and activate the virtual environment:
python3 -m venv .venv
chmod 755 .venv/bin/activate
source .venv/bin/activate
- Install the laser-mind-client package.
pip install laser-mind-client
- (Recommended) Test using one of the provided test examples. Under the above project folder unzip "lightsolver_onboarding.zip."
cd lightsolver_onboarding
open test_solve_qubo_matrix.py file for edit
enter the provided TOKEN in line 6 (userToken = "<my_token>")
python3 ./tests/test_solve_qubo_matrix.py
Authentication
Initialization of the LaserMind class automatically forms a secure and authenticated connection with the LightSolver Cloud.
Subsequent calls by the same user are similarly secure and authenticated.
Usage
To begin solving any QUBO problem:
- Create an instance of the
LaserMindclass. This class represents the client that requests solutions from the LightSolver Cloud. - By default, all logs are printed to laser-mind.log file in current directory and to console. Output to console can be disabled by setting
logToConsole=False - Call the
solve_qubofunction using either a matrix or an adjacency list. Note: You may either provide a value formatrixDataor foredgeList, but not both.
Examples
Find examples of every feature in laser-mind-client under the "tests/" directory.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file laser_mind_client-0.31.6.tar.gz.
File metadata
- Download URL: laser_mind_client-0.31.6.tar.gz
- Upload date:
- Size: 12.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
46d35f2c4f8083ebaea87325e10169d55a66836ee2d15ae02c99c952dfbb50f2
|
|
| MD5 |
c04fcd01853fab097d999e7e3624ac96
|
|
| BLAKE2b-256 |
8554d6267d85aa3001f8803fdbaf7fa05a9ecf64fe8b9e06eb36ef2e7ae81cf5
|
Provenance
The following attestation bundles were made for laser_mind_client-0.31.6.tar.gz:
Publisher:
build-publish-pypi.yml on LightSolverInternal/laser-mind-client
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
laser_mind_client-0.31.6.tar.gz -
Subject digest:
46d35f2c4f8083ebaea87325e10169d55a66836ee2d15ae02c99c952dfbb50f2 - Sigstore transparency entry: 174152892
- Sigstore integration time:
-
Permalink:
LightSolverInternal/laser-mind-client@1878af83994d7cff7b321ab0388ac95f72ec9ec8 -
Branch / Tag:
refs/heads/production - Owner: https://github.com/LightSolverInternal
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
self-hosted -
Publication workflow:
build-publish-pypi.yml@1878af83994d7cff7b321ab0388ac95f72ec9ec8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file laser_mind_client-0.31.6-py3-none-any.whl.
File metadata
- Download URL: laser_mind_client-0.31.6-py3-none-any.whl
- Upload date:
- Size: 11.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be93308decb6e3de52ed570c865d22eefe954922e67860ac34b27f9e850c72f2
|
|
| MD5 |
a9625835a578a7aff20f6f3365002622
|
|
| BLAKE2b-256 |
17248c2ba5b1eab39528db108aa576c2ee205f97a92efa93af965a94eefab82e
|
Provenance
The following attestation bundles were made for laser_mind_client-0.31.6-py3-none-any.whl:
Publisher:
build-publish-pypi.yml on LightSolverInternal/laser-mind-client
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
laser_mind_client-0.31.6-py3-none-any.whl -
Subject digest:
be93308decb6e3de52ed570c865d22eefe954922e67860ac34b27f9e850c72f2 - Sigstore transparency entry: 174152896
- Sigstore integration time:
-
Permalink:
LightSolverInternal/laser-mind-client@1878af83994d7cff7b321ab0388ac95f72ec9ec8 -
Branch / Tag:
refs/heads/production - Owner: https://github.com/LightSolverInternal
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
self-hosted -
Publication workflow:
build-publish-pypi.yml@1878af83994d7cff7b321ab0388ac95f72ec9ec8 -
Trigger Event:
push
-
Statement type: