Phoenix Computation SDK API Doc
  • Welcome
  • Quick Start
  • Reference
    • API Reference
      • Users
      • Job Operations
      • Job Queries
      • PhoenixLLM
      • PhoenixGenAI
      • Distributed AI
Powered by GitBook
On this page
  • Uploading Dataset
  • Evaluating CCD Cost for CNN
  • Evaluating CCD Cost for LSTM
  • Creating a CNN Job
  • Creating a LSTM Job
  • Evaluating CCD Cost for Inference
  • Inference
  • Querying Inference Result
  • Querying Inference Result List
  1. Reference
  2. API Reference

Distributed AI

Good to know: All Distributed AI interfaces need to use token as the request header.

Uploading Dataset

Upload the dataset to obtain a file path as a parameter of other APIs.

POST https://www.phoenix.global/sdk/computation/deAI/uploadFile

Upload a file to server

Headers

Name
Type
Description

token*

string

The access token generated in the previous step

Content-Type*

multipart/form-data

content type

Request Body

Name
Type
Description

file*

file

Dataset file

{
    "code":200,
    "msg":"111@gmail.com/2023-10-24T12:07:12Zy_train.csv"
}

The usage of curl and golang sdk is as follows:

curl --location 'https://www.phoenix.global/sdk/computation/deAI/uploadFile' \
--header 'token: eyJhbGciOiJIUzIxxxxxxxxxxxxx' \
--form 'file=@"your local file path"'
import (
	"github.com/PhoenixGlobal/Phoenix-Computation-SDK/controllers"
)

func main() {
	genTokenBody := common.ReqGenToken{
		Email:  "xxx@gmail.com",
		Passwd: "xxxxxxxxxxx",
	}
	genTokenResult, err := controllers.GenToken(genTokenBody)
	tokenMap := make(map[string]interface{})
	err = json.Unmarshal(genTokenResult, &tokenMap)
	token := tokenMap["token"].(string)
	fileName := "absolute file path"
	result, err := controllers.UploadDeAIFile(fileName, token)
	......
}

Evaluating CCD Cost for CNN

POST https://www.phoenix.global/sdk/computation/deAI/queryGuarantee

Evaluate the number of ccds required for training CNN model

Headers

Name
Type
Description

token*

string

The access token generated in the previous step

Request Body

Name
Type
Description

model*

string

Model name, which is CNN

epoch*

integer

The epoch for training

jobName*

string

Job name

x_train*

string

The path of the training dataset, obtained by calling the upload file api

y_train

string

The path of the label dataset, obtained by calling the upload file api

train_shard*

float

A decimal number greater than 0 and less than 1, indicating the proportion used for training

scale_ratio

integer

The number of colors in the picture

category*

int

Number of categories

channel

int

Image channel

{
    "code": 200,
    "msg": "success",
    "ccd_cost": 27870365208168000
}

The usage of curl and golang sdk is as follows:

curl --location 'https://www.phoenix.global/sdk/computation/deAI/queryGuarantee' \
--header 'token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJFbWFpbCI6IjExMUBnbWFpbC5jb20iLCJleHAiOjE2OTgxNTg1ODl9.lZPScQLs1ScGS6KPqUp1lg5XdOqnGLQyOsO3wMugps8' \
--header 'Content-Type: application/json' \
--data-raw '{
  "epoch": 2,
  "jobName": "CNN Classification Job",
  "model": "CNN",
  "scale_ratio": 255,
  "category": 3,
  "channel": 1,
  "train_shard": 0.8,
  "x_train": "111@gmail.com/2023-10-24T13:42:46Zx_train.zip",
  "y_train": "111@gmail.com/2023-10-24T13:22:36Zy_train.csv"
}'
import (
	"github.com/PhoenixGlobal/Phoenix-Computation-SDK/common"
	"github.com/PhoenixGlobal/Phoenix-Computation-SDK/controllers"
)

func main() {
	genTokenBody := common.ReqGenToken{
		Email:  "xxx@gmail.com",
		Passwd: "xxxxxxxxxxx",
	}
	genTokenResult, err := controllers.GenToken(genTokenBody)
	tokenMap := make(map[string]interface{})
	err = json.Unmarshal(genTokenResult, &tokenMap)
	token := tokenMap["token"].(string)
	req := common.ReqQueryFlops{
		JobName:    "CNN Classification Job",
		TrainData:  "222@gmail.com/2023-11-01T03:25:25Zx_train.zip",
		TrainLable: "222@gmail.com/2023-11-01T03:26:20Zy_train.csv",
		Epoch:      3,
		Model:      "CNN",
		TrainShard: 0.8,
		Category:   2,
		Channel:    1,
		ScaleRatio: 255,
	}
	res, err := controllers.QueryAICcdCost(req, token)
	......
}

Evaluating CCD Cost for LSTM

POST https://www.phoenix.global/sdk/computation/deAI/queryGuarantee

Evaluate the number of ccds required for training LSTM model

Headers

Name
Type
Description

token*

string

The access token generated in the previous step

Request Body

Name
Type
Description

jobName*

string

Job name

model*

string

Model name, which is LSTM

epoch*

integer

The epoch for training

x_train*

string

The path of the training dataset, obtained by calling the upload file api

train_shard*

float

A decimal number greater than 0 and less than 1, indicating the proportion used for training

input_width*

integer

label_width*

integer

shift*

integer

sequence_stride*

integer

sampling_rate

integer

{
    "code": 200,
    "msg": "success",
    "ccd_cost": 27870365208168000
}

The usage of curl and golang sdk is as follows:

curl --location 'https://www.phoenix.global/sdk/computation/deAI/queryGuarantee' \
--header 'token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJFbWFpbCI6IjExMUBnbWFpbC5jb20iLCJleHAiOjE2OTgxNTg1ODl9.lZPScQLs1ScGS6KPqUp1lg5XdOqnGLQyOsO3wMugps8' \
--header 'Content-Type: application/json' \
--data-raw '{
  "epoch": 2,
  "jobName": "LSTM Job",
  "model": "LSTM",
  "train_shard": 0.8,
  "x_train": "111@gmail.com/2023-10-24T13:53:15Zjena_climate.csv",
  "input_width":24,
  "label_width":24,
  "shift":24,
  "sequence_stride":1,
  "sampling_rate":1
}'
package main

import (
	"github.com/PhoenixGlobal/Phoenix-Computation-SDK/common"
	"github.com/PhoenixGlobal/Phoenix-Computation-SDK/controllers"
)

func main() {
	genTokenBody := common.ReqGenToken{
		Email:  "xxx@gmail.com",
		Passwd: "xxxxxxxxxxx",
	}
	genTokenResult, err := controllers.GenToken(genTokenBody)
	tokenMap := make(map[string]interface{})
	err = json.Unmarshal(genTokenResult, &tokenMap)
	token := tokenMap["token"].(string)
	req := common.ReqQueryFlops{
		JobName:        "LSTM Job",
		TrainData:      "222@gmail.com/2023-10-24T13:53:15Zjena_climate.csv",
		Epoch:          3,
		Model:          "LSTM",
		TrainShard:     0.8,
		InputWidth:     24,
		LabelWidth:     24,
		Shift:          24,
		SequenceStride: 1,
		SamplingRate:   1,
	}
	res, err := controllers.QueryAICcdCost(req, token)
	......
}

Creating a CNN Job

POST https://www.phoenix.global/sdk/computation/deAI/createJob

Creating a CNN job

Headers

Name
Type
Description

token*

string

The access token generated in the previous step

Request Body

Name
Type
Description

jobName*

string

Job Name

batchSize*

integer

batch size

computation*

string

Computation type, which is Distributed AI

{
    "code":200,
    "msg":"Success",
    "data":"59576164105114941297104078936238635731163357384303362249410479244945241708329"
}

The usage of curl and golang sdk is as follows:

curl --location 'https://www.phoenix.global/sdk/computation/deAI/createJob' \
--header 'token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJFbWFpbCI6IjExMUBnbWFpbC5jb20iLCJleHAiOjE2OTgxNTg1ODl9.lZPScQLs1ScGS6KPqUp1lg5XdOqnGLQyOsO3wMugps8' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jobName": "CNN Classification Job",
    "computation": "Distributed AI",
    "batchSize": 64
}'
import (
	"github.com/PhoenixGlobal/Phoenix-Computation-SDK/common"
	"github.com/PhoenixGlobal/Phoenix-Computation-SDK/controllers"
)

func main() {
	genTokenBody := common.ReqGenToken{
		Email:  "xxx@gmail.com",
		Passwd: "xxxxxxxxxxx",
	}
	genTokenResult, err := controllers.GenToken(genTokenBody)
	tokenMap := make(map[string]interface{})
	err = json.Unmarshal(genTokenResult, &tokenMap)
	token := tokenMap["token"].(string)
	req := common.ReqCreateAIJob{
		JobName:     "CNN Classification Job",
		Computation: "Distributed AI",
		BatchSize:   64,
	}
	res, err := controllers.CreateAIJob(req, token)
	......
}

Creating a LSTM Job

POST https://www.phoenix.global/sdk/computation/deAI/createJob

Creating a LSTM Job

Headers

Name
Type
Description

token*

string

The access token generated in the previous step

Request Body

Name
Type
Description

jobName*

string

Job name

batchSize

integer

batch size

computation

string

Computation type, which is Distributed AI

{
    "code":200,
    "msg":"Success",
    "data":"59576164105114941297104078936238635731163357384303362249410479244945241708329"
}

The usage of curl and golang sdk is as follows:

curl --location 'https://www.phoenix.global/sdk/computation/deAI/createJob' \
--header 'token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJFbWFpbCI6IjExMUBnbWFpbC5jb20iLCJleHAiOjE2OTgxNTg1ODl9.lZPScQLs1ScGS6KPqUp1lg5XdOqnGLQyOsO3wMugps8' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jobName": "LSTM Job",
    "computation": "Distributed AI",
    "batchSize": 64
}'
import (
	"github.com/PhoenixGlobal/Phoenix-Computation-SDK/common"
	"github.com/PhoenixGlobal/Phoenix-Computation-SDK/controllers"
)

func main() {
	genTokenBody := common.ReqGenToken{
		Email:  "xxx@gmail.com",
		Passwd: "xxxxxxxxxxx",
	}
	genTokenResult, err := controllers.GenToken(genTokenBody)
	tokenMap := make(map[string]interface{})
	err = json.Unmarshal(genTokenResult, &tokenMap)
	token := tokenMap["token"].(string)
	req := common.ReqCreateAIJob{
		JobName:        "LSTM Job",
		Computation:    "Distributed AI",
		BatchSize:      64,
	}
	res, err := controllers.CreateAIJob(req, token)
	......
}

Evaluating CCD Cost for Inference

POST https://www.phoenix.global/sdk/computation/deAI/inferenceCost

Evaluating ccd cost for inference

Headers

Name
Type
Description

token*

string

The access token generated in the previous step

Request Body

Name
Type
Description

data_path*

string

The path of the dataset, obtained by calling the upload file api

jobID*

string

The job id of a distributed AI job

{
    "code": 200,
    "msg": "success",
    "ccd_cost": 13271602480080000
}

The usage of curl and golang sdk is as follows:

curl --location 'https://www.phoenix.global/sdk/computation/deAI/inferenceCost' \
--header 'token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJFbWFpbCI6IjIyMkBnbWFpbC5jb20iLCJleHAiOjE3MDAwMzQ2NTN9.0NhuhoPX-AuIxjRiF0V4N-idYr_3tAjTUEafOD67DS0' \
--header 'Content-Type: application/json' \
--data-raw '{
  "data_path": "222@gmail.com/2023-11-15T06:00:19Zx_train.zip",
  "jobID": "86336785146289395195200824626469818031842412882953927198307248471561534896799"
}'
package main

import (
	"github.com/PhoenixGlobal/Phoenix-Computation-SDK/common"
	"github.com/PhoenixGlobal/Phoenix-Computation-SDK/controllers"
)
func main() {
	token := "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJFbWFpbCI6IjIyMkBnbWFpbC5jb20iLCJleHAiOjE3MDAwMzA3NTB9.T4aB0gyUneFerrGd2IZGHh6pjtvi9TH4IMT01ZaRzo8"
	jobID := "86336785146289395195200824626469818031842412882953927198307248471561534896799"
	dataPath := "222@gmail.com/2023-11-15T06:00:19Zx_train.zip"
	req := common.ReqInferenceCost{
		JobID:    jobID,
		DataPath: dataPath,
	}
	res, err := controllers.QueryInferCost(req, token)
	......
}

Inference

POST https://www.phoenix.global/sdk/computation/deAI/inference

Inference

Headers

Name
Type
Description

token*

string

The access token generated in the previous step

Request Body

Name
Type
Description

jobID*

string

The job id of a distributed AI job

{
    "code": 200,
    "msg": "Inference success",
    "infer_id": 13
}

The usage of curl and golang sdk is as follows:

curl --location 'https://www.phoenix.global/sdk/computation/deAI/inference' \
--header 'token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJFbWFpbCI6IjIyMkBnbWFpbC5jb20iLCJleHAiOjE3MDAwMzQ2NTN9.0NhuhoPX-AuIxjRiF0V4N-idYr_3tAjTUEafOD67DS0' \
--header 'Content-Type: application/json' \
--data '{
  "jobID": "86336785146289395195200824626469818031842412882953927198307248471561534896799"
}'
package main

import (
	"github.com/PhoenixGlobal/Phoenix-Computation-SDK/common"
	"github.com/PhoenixGlobal/Phoenix-Computation-SDK/controllers"
)

func main() {
	token := "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJFbWFpbCI6IjIyMkBnbWFpbC5jb20iLCJleHAiOjE3MDAwMzgwMjh9.HJT8uy4CL5Lqx-L9E4Mx0NOcKzIPsBbt48v3_kObKno"
	jobID := "86336785146289395195200824626469818031842412882953927198307248471561534896799"
	req := common.ReqInference{
		JobID: jobID,
	}
	res, err := controllers.InferenceJob(req, token)
	......
}

Querying Inference Result

POST https://www.phoenix.global/sdk/computation/deAI/queryInfer

Querying a inference result by id

Headers

Name
Type
Description

token*

string

The access token generated in the previous step

Request Body

Name
Type
Description

id*

string

The inference id, obtained by calling the inference api

{
    "code": 200,
    "msg": "success",
    "data": {
        "tx_hash": "0x76233b90445f34e6c0c19d056b3d04ec06c2f36844c6b777c74493a9b3ea3124",
        "result": "https://phoenix.global/ai/resultFiles/predicted_222@gmail.com_5CNN_mnist.csv",
        "submitTime": 1700037265,
        "ccd_cost": "0.01327160248"
    }
}

The usage of curl and golang sdk is as follows:

curl --location 'https://www.phoenix.global/sdk/computation/deAI/queryInfer' \
--header 'token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJFbWFpbCI6IjIyMkBnbWFpbC5jb20iLCJleHAiOjE3MDAwMzkzMjV9.gKHqa2-Q7zxFcEle0bzv-o8x2__1949TWDclZrAK51Q' \
--header 'Content-Type: application/json' \
--data '{
  "id": 21
}'
package main

import (
	"github.com/PhoenixGlobal/Phoenix-Computation-SDK/common"
	"github.com/PhoenixGlobal/Phoenix-Computation-SDK/controllers"
)

func main() {
	token := "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJFbWFpbCI6IjIyMkBnbWFpbC5jb20iLCJleHAiOjE3MDAwMzkzMjV9.gKHqa2-Q7zxFcEle0bzv-o8x2__1949TWDclZrAK51Q"
	inferenceID := int64(21)
	req := common.ReqQueryInferByID{
		ID: inferenceID,
	}
	res, err := controllers.QueryInference(req, token)
	......
}

Querying Inference Result List

POST https://www.phoenix.global/sdk/computation/deAI/queryInferList

Querying inference result list

Headers

Name
Type
Description

token*

string

The access token generated in the previous step

Request Body

Name
Type
Description

pageNo*

integer

Page number

pageSize*

integer

Page size

jobID*

string

Job id

{
    "code": 200,
    "msg": "success",
    "size": 10,
    "page": 1,
    "totalPages": 1,
    "totalCount": 2,
    "data": [
        {
            "tx_hash": "0x76233b90445f34e6c0c19d056b3d04ec06c2f36844c6b777c74493a9b3ea3124",
            "result": "https://phoenix.global/ai/resultFiles/predicted_222@gmail.com_5CNN_mnist.csv",
            "submitTime": 1700037265,
            "ccd_cost": "0.01327160248"
        },
        {
            "tx_hash": "0x7ff8ee03deb93d608503bb59c183ecc9ed0e16be9599289af0938b4c20bdd91c",
            "result": "https://phoenix.global/ai/resultFiles/predicted_222@gmail.com_4CNN_mnist.csv",
            "submitTime": 1700037108,
            "ccd_cost": "0.01327160248"
        }
    ]
}

The usage of curl and golang sdk is as follows:

curl --location 'https://www.phoenix.global/sdk/computation/deAI/queryInferList' \
--header 'token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJFbWFpbCI6IjIyMkBnbWFpbC5jb20iLCJleHAiOjE3MDAwNDM4ODN9.i68m1VKJ894NxAd83HXGLUkvrobmAJ3yWo3aJPs4YT4' \
--header 'Content-Type: application/json' \
--data '{
  "jobID": "86336785146289395195200824626469818031842412882953927198307248471561534896799",
  "pageNo": 1,
  "pageSize": 10
}'
package main

import (
	"github.com/PhoenixGlobal/Phoenix-Computation-SDK/common"
	"github.com/PhoenixGlobal/Phoenix-Computation-SDK/controllers"
)

func main() {
	token := "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJFbWFpbCI6IjIyMkBnbWFpbC5jb20iLCJleHAiOjE3MDAwMzkzMjV9.gKHqa2-Q7zxFcEle0bzv-o8x2__1949TWDclZrAK51Q"
	jobID := "86336785146289395195200824626469818031842412882953927198307248471561534896799"
	req := common.ReqQueryInfer{
		ReqPage: &common.ReqPage{
			PageNo:   1,
			PageSize: 10,
		},
		JobID: jobID,
	}
	res, err := controllers.QueryInferList(req, token)
	......
}
PreviousPhoenixGenAI

Please refer to the website:

Please refer to the website:

Please refer to the website:

Please refer to the website:

Please refer to the website:

https://www.tensorflow.org/tutorials/structured_data/time_series#data_windowing
https://www.tensorflow.org/tutorials/structured_data/time_series#data_windowing
https://www.tensorflow.org/tutorials/structured_data/time_series#data_windowing
https://www.tensorflow.org/tutorials/structured_data/time_series#data_windowing
https://www.tensorflow.org/tutorials/structured_data/time_series#data_windowing