Skip to content

Commit

Permalink
Merge remote-tracking branch 'pokt/main' into chore/cleanup-localnet-…
Browse files Browse the repository at this point in the history
…testutils

* pokt/main:
  [LocalNet] Add infrastructure to run LLM inference (#508)
  • Loading branch information
bryanchriswhite committed May 6, 2024
2 parents 48921fa + 3dee9c1 commit ee1d9b9
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 16 deletions.
46 changes: 35 additions & 11 deletions Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ load("ext://restart_process", "docker_build_with_restart")
load("ext://helm_resource", "helm_resource", "helm_repo")
load("ext://configmap", "configmap_create")
load("ext://secret", "secret_create_generic")
load("ext://deployment", "deployment_create")
load("ext://execute_in_pod", "execute_in_pod")

# A list of directories where changes trigger a hot-reload of the validator
hot_reload_dirs = ["app", "cmd", "tools", "x", "pkg"]


def merge_dicts(base, updates):
for k, v in updates.items():
if k in base and type(base[k]) == "dict" and type(v) == "dict":
Expand All @@ -16,6 +19,7 @@ def merge_dicts(base, updates):
# Replace or set the value
base[k] = v


# Create a localnet config file from defaults, and if a default configuration doesn't exist, populate it with default values
localnet_config_path = "localnet_config.yaml"
localnet_config_defaults = {
Expand All @@ -28,17 +32,19 @@ localnet_config_defaults = {
"delve": {"enabled": False},
},
"observability": {"enabled": True},
"relayminers": {
"count": 1,
"delve": {"enabled": False}
},
"relayminers": {"count": 1, "delve": {"enabled": False}},
"gateways": {
"count": 1,
"delve": {"enabled": False},
"delve": {"enabled": False},
},
"appgateservers": {
"count": 1,
"delve": {"enabled": False},
"delve": {"enabled": False},
},
# TODO(#511): Add support for `REST` and enabled this.
"ollama": {
"enabled": False,
"model": "qwen:0.5b",
},
# By default, we use the `helm_repo` function below to point to the remote repository
# but can update it to the locally cloned repo for testing & development
Expand All @@ -54,7 +60,9 @@ merge_dicts(localnet_config, localnet_config_defaults)
# Then merge file contents over defaults
merge_dicts(localnet_config, localnet_config_file)
# Check if there are differences or if the file doesn't exist
if (localnet_config_file != localnet_config) or (not os.path.exists(localnet_config_path)):
if (localnet_config_file != localnet_config) or (
not os.path.exists(localnet_config_path)
):
print("Updating " + localnet_config_path + " with defaults")
local("cat - > " + localnet_config_path, stdin=encode_yaml(localnet_config))

Expand Down Expand Up @@ -198,10 +206,8 @@ helm_resource(
"--values=./localnet/kubernetes/values-validator.yaml",
"--set=persistence.cleanupBeforeEachStart="
+ str(localnet_config["validator"]["cleanupBeforeEachStart"]),
"--set=logs.level="
+ str(localnet_config["validator"]["logs"]["level"]),
"--set=logs.format="
+ str(localnet_config["validator"]["logs"]["format"]),
"--set=logs.level=" + str(localnet_config["validator"]["logs"]["level"]),
"--set=logs.format=" + str(localnet_config["validator"]["logs"]["format"]),
"--set=serviceMonitor.enabled="
+ str(localnet_config["observability"]["enabled"]),
"--set=development.delve.enabled="
Expand Down Expand Up @@ -364,3 +370,21 @@ k8s_resource(
)

k8s_resource("anvil", labels=["data_nodes"], port_forwards=["8547"])

if localnet_config["ollama"]["enabled"]:
print("Ollama enabled: " + str(localnet_config["ollama"]["enabled"]))

deployment_create(
"ollama",
image="ollama/ollama",
command=["ollama", "serve"],
ports="11434",
)

local_resource(
name="ollama-pull-model",
cmd=execute_in_pod(
"ollama", "ollama pull " + localnet_config["ollama"]["model"]
),
resource_deps=["ollama"],
)
10 changes: 10 additions & 0 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ genesis:
- service:
id: anvil
name: ""
- service:
id: ollama
name: ""
stake:
# NB: This value should be exactly 1upokt smaller than the value in
# `supplier1_stake_config.yaml` so that the stake command causes a state change.
Expand All @@ -148,6 +151,13 @@ genesis:
service:
id: anvil
name: ""
- endpoints:
- configs: []
rpc_type: REST
url: http://relayminer1:8545
service:
id: ollama
name: ""
stake:
# NB: This value should be exactly 1upokt smaller than the value in
# `application1_stake_config.yaml` so that the stake command causes a state change.
Expand Down
6 changes: 6 additions & 0 deletions localnet/kubernetes/values-relayminer-1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ config:
backend_url: http://anvil:8547/
publicly_exposed_endpoints:
- relayminer1
- service_id: ollama
listen_url: http://0.0.0.0:8545
service_config:
backend_url: http://ollama:11434/
publicly_exposed_endpoints:
- relayminer1
6 changes: 6 additions & 0 deletions localnet/kubernetes/values-relayminer-2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ config:
backend_url: http://anvil:8547/
publicly_exposed_endpoints:
- relayminer2
- service_id: ollama
listen_url: http://0.0.0.0:8545
service_config:
backend_url: http://ollama:11434/
publicly_exposed_endpoints:
- relayminer2
6 changes: 6 additions & 0 deletions localnet/kubernetes/values-relayminer-3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ config:
backend_url: http://anvil:8547/
publicly_exposed_endpoints:
- relayminer3
- service_id: ollama
listen_url: http://0.0.0.0:8545
service_config:
backend_url: http://ollama:11434/
publicly_exposed_endpoints:
- relayminer3
8 changes: 6 additions & 2 deletions localnet/poktrolld/config/supplier1_stake_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ services:
- service_id: svc1
endpoints:
- url: http://localhost:8081
rpc_type: json_rpc
rpc_type: JSON_RPC
# The endpoint URL for the Anvil service is provided via the RelayMiner.
# The RelayMiner acts as a proxy, forwarding requests to the actual Anvil data node behind it.
# This setup allows for flexible and dynamic service provisioning within the network.
- service_id: anvil
endpoints:
- publicly_exposed_url: http://relayminer1:8545
rpc_type: json_rpc
rpc_type: JSON_RPC
- service_id: ollama
endpoints:
- publicly_exposed_url: http://relayminer1:8545
rpc_type: REST
6 changes: 5 additions & 1 deletion localnet/poktrolld/config/supplier2_stake_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ services:
# The RelayMiner acts as a proxy, forwarding requests to the actual Anvil data node behind it.
# This setup allows for flexible and dynamic service provisioning within the network.
- publicly_exposed_url: http://relayminer2:8545
rpc_type: json_rpc
rpc_type: JSON_RPC
- service_id: ollama
endpoints:
- publicly_exposed_url: http://relayminer2:8545
rpc_type: REST
6 changes: 5 additions & 1 deletion localnet/poktrolld/config/supplier3_stake_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ services:
# The RelayMiner acts as a proxy, forwarding requests to the actual Anvil data node behind it.
# This setup allows for flexible and dynamic service provisioning within the network.
- publicly_exposed_url: http://relayminer3:8545
rpc_type: json_rpc
rpc_type: JSON_RPC
- service_id: ollama
endpoints:
- publicly_exposed_url: http://relayminer3:8545
rpc_type: REST
3 changes: 2 additions & 1 deletion x/supplier/config/supplier_configs_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package config

import (
"net/url"
"strings"

sdk "github.com/cosmos/cosmos-sdk/types"
"gopkg.in/yaml.v2"
Expand Down Expand Up @@ -175,7 +176,7 @@ func parseEndpointConfigs(endpoint YAMLServiceEndpoint) ([]*sharedtypes.ConfigOp

// parseEndpointRPCType parses the endpoint RPC type into a sharedtypes.RPCType
func parseEndpointRPCType(endpoint YAMLServiceEndpoint) (sharedtypes.RPCType, error) {
switch endpoint.RPCType {
switch strings.ToLower(endpoint.RPCType) {
case "json_rpc":
return sharedtypes.RPCType_JSON_RPC, nil
default:
Expand Down

0 comments on commit ee1d9b9

Please sign in to comment.