Skip to content
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

Features/streaming #103

Merged
merged 82 commits into from
Mar 12, 2024
Merged

Features/streaming #103

merged 82 commits into from
Mar 12, 2024

Conversation

mccrindlebrian
Copy link
Contributor

@mccrindlebrian mccrindlebrian commented Feb 14, 2024

This PR provides functionality for validator and miner streaming.

Key Points

  1. Removal of docs/stream_tutorial to clean up repo
  2. Deprecation of BaseMinerNeuron, into a new BaseStreamMinerNeuron that changes the requirements for miner forward method
  3. Validator forward method now includes a handle_response function, which handles the async calls to the appropriate miners and acquires their completed StreamPromptingSynapses'
  4. Langchain miners (HF) now store the response in a background Queue handled by a CustomTextStreamerIterator. Langchain miners are thrown onto a new thread where generations are done in batches of config.neuron.streaming_batch_size. When the generation is done, the threads are closed, and the Queue is dumped. In cases where timeout is reached, the Queue will not be empty, and on subsequent calls to the miner they will reply with tokens generated from the previous uncompleted request. This is undesirable, so we forcibly clear this Queue.
  5. load_pipeline can now return streamer classes like the one mentioned in point 4
  6. The prompting.protocol holds the StreamPromptingSynapse and is used to decode streamed chunks.
  7. We include a new script called client.py to ping a miner on testnet without running a validator.
  8. A new MockDendrite and MockStreamMiner are included in the mock.py file for testing purposes.

Block Diagram

This is a rough idea of what is happening during streaming for the most complicated case (langchain)
image

Limitations

  1. get_openai_callback from langchain doesn't seem to integrate easily with the async calls that occur in the _forward method. This callback is used to track overall costs and openai information. I was unable to get this to work within a satisfactory amount of time, so therefore openai based miners do not use the callback anymore. This is a direction for future work.

@mccrindlebrian mccrindlebrian changed the base branch from staging to features/hf-miner February 14, 2024 03:15
@steffencruz
Copy link
Collaborator

Still needs a README

mccrindlebrian and others added 2 commits March 12, 2024 13:20
@steffencruz steffencruz merged commit 91330cf into pre-staging Mar 12, 2024
2 of 3 checks passed
@p-ferreira p-ferreira mentioned this pull request Apr 4, 2024
@mccrindlebrian mccrindlebrian deleted the features/streaming branch April 16, 2024 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants