Skip to content

Commit

Permalink
feat(bid-script): use highest price when model detection fails
Browse files Browse the repository at this point in the history
Partially addresses akash-network/support#139
  • Loading branch information
andy108369 committed Nov 3, 2023
1 parent 731046f commit f5c6152
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion charts/akash-provider/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type: application
# Versions are expected to follow Semantic Versioning (https://semver.org/)

# Major version bit highlights the mainnet release (e.g. mainnet4 = 4.x.x, mainnet5 = 5.x.x, ...)
version: 6.0.6
version: 6.0.7

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
17 changes: 13 additions & 4 deletions charts/akash-provider/scripts/price_script_generic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -134,24 +134,33 @@ TARGET_IP="${PRICE_TARGET_IP:-5}" # USD for leased IP/mon
##

# Populate the price target gpu_mappings dynamically based on the "price_target_gpu_mappings" value passed by the helm-chart
# Default: "a100=120,t4=80,*=130"
declare -A gpu_mappings=()

IFS=',' read -ra PAIRS <<< "${PRICE_TARGET_GPU_MAPPINGS:-a100=120,t4=80,*=130}"
IFS=',' read -ra PAIRS <<< "${PRICE_TARGET_GPU_MAPPINGS}"
for pair in "${PAIRS[@]}"; do
IFS='=' read -ra KV <<< "$pair"
key="${KV[0]}"
value="${KV[1]}"
gpu_mappings["$key"]=$value
done

gpu_price_total=0
# Default to 100 USD/GPU per unit a month when PRICE_TARGET_GPU_MAPPINGS is not set
# Or use the highest price from PRICE_TARGET_GPU_MAPPINGS when model detection fails (ref. https://github.com/akash-network/support/issues/139 )
gpu_unit_max_price=100
for value in "${gpu_mappings[@]}"; do
if (( value > gpu_unit_max_price )); then
gpu_unit_max_price=$value
fi
done

echo "DEBUG: gpu_unit_max_price $gpu_unit_max_price"

gpu_price_total=0
while IFS= read -r resource; do
model=$(echo "$resource" | jq -r '.gpu.attributes.vendor.nvidia.model // 0')
gpu_units=$(echo "$resource" | jq -r '.gpu.units // 0')
# default to 100 USD/GPU per unit a month when PRICE_TARGET_GPU_MAPPINGS is not set
price="${gpu_mappings[''$model'']:-100}"
price="${gpu_mappings[''$model'']:-$gpu_unit_max_price}"
((gpu_price_total += gpu_units * price))

if ! [[ -z $DEBUG_BID_SCRIPT ]]; then
Expand Down

0 comments on commit f5c6152

Please sign in to comment.