Skip to content

Commit

Permalink
repo move
Browse files Browse the repository at this point in the history
  • Loading branch information
ajbalogh committed May 9, 2024
1 parent 85e8b07 commit 258691b
Show file tree
Hide file tree
Showing 23 changed files with 2,075 additions and 2 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Models build, test and optionally create release

on:
push:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Output
env:
PRN: ${{github.event_path.pull_request.number}}
GITHUB_CONTEXT: ${{ toJSON(github) }}
run: echo "$GITHUB_CONTEXT"

- name: Checkout Repository
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}

- name: Sets up Python
uses: actions/setup-python@v2
with:
python-version: "3.10"

- name: Compile protos and run tests
run: |
make env
make test
- uses: dorny/paths-filter@v2
id: change
with:
filters: |
version:
- 'VERSION'
- name: Read VERSION file
if: github.event_name == 'push' && github.ref_name == 'main' && steps.change.outputs.version == 'true'
id: getversion
run: |
echo "version=$(cat VERSION)" >> $GITHUB_OUTPUT
echo "3.10"
- name: Create release
if: github.event_name == 'push' && github.ref_name == 'main' && steps.change.outputs.version == 'true'
id: create_release
uses: actions/create-release@v1
with:
draft: false
prerelease: false
release_name: v${{steps.getversion.outputs.version}}+${{github.ref_name}}
tag_name: v${{steps.getversion.outputs.version}}+${{github.ref_name}}
env:
GITHUB_TOKEN: ${{ github.token }}

- name: Upload release artifact
if: github.event_name == 'push' && github.ref_name == 'main' && steps.change.outputs.version == 'true'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: dist/mlcommons_chakra-${{steps.getversion.outputs.version}}+${{github.ref_name}}-py3-none-any.whl
asset_name: mlcommons_chakra-${{steps.getversion.outputs.version}}+${{github.ref_name}}-py3-none-any.whl
asset_content_type: application/gzip
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
__pycache__/
*.py[cod]
*$py.class
.ipynb_checkpoints
src/tests/*.html
src/tests/*.yml
.yml
build
dist
.pytest_cache
*.egg-info
src/generated
src/tests/generated_artifacts
15 changes: 15 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"recommendations": [
"ms-python.black-formatter",
"ms-toolsai.jupyter",
"ms-toolsai.vscode-jupyter-cell-tags",
"ms-toolsai.jupyter-renderers",
"ms-toolsai.vscode-jupyter-slideshow",
"ms-vscode.live-server",
"esbenp.prettier-vscode",
"ms-python.vscode-pylance",
"ms-python.python",
"zxh404.vscode-proto3",
"redhat.vscode-yaml"
]
}
27 changes: 27 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"editor.formatOnSave": true,
"editor.rulers": [ 80 ],
"json.format.enable": true,
"yaml.format.enable": true,
"json.format.keepLines": true,
"python.analysis.typeCheckingMode": "off",
"[yaml]": {
"editor.tabSize": 2,
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[proto]": {
"editor.wordWrap": "off",
"editor.tabSize": 2,
"editor.defaultFormatter": "xaver.clang-format"
},
"[proto3]": {
"editor.defaultFormatter": "xaver.clang-format"
},
"protoc": {
"options": [
"--proto_path=${workspaceFolder}/protos"
]
},
"clang-format.language.proto.enable": true,
"clang-format.language.proto.style": "{ IndentWidth: 2, BasedOnStyle: google, ReflowComments: false, ColumnLimit: 0, AlignTrailingComments: true }",
}
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include ./VERSION
include ./src/generated/*.proto
include ./src/generated/*.pyi
26 changes: 26 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
help:
@awk -F ':|##' '/^[^\t].+:.*##/ { printf "\033[36mmake %-28s\033[0m -%s\n", $$1, $$NF }' $(MAKEFILE_LIST) | sort

env: ## install env requirements
echo "installing python packages..." && \
pip install -r requirements.txt

.PHONY: build
GENERATED_DIR := ./src/generated
build: ## compile all .proto files and generate artifacts
curl -L -o ./protos/et_def.proto https://raw.githubusercontent.com/mlcommons/chakra/main/schema/protobuf/et_def.proto
rm -rf $(GENERATED_DIR) || true
mkdir -p $(GENERATED_DIR)
python3 -m grpc_tools.protoc \
--proto_path=./protos \
--python_out=$(GENERATED_DIR) --pyi_out=$(GENERATED_DIR) \
et_def.proto infra.proto
python3 -m pip uninstall -y mlcommons-chakra
python3 setup.py bdist_wheel
python3 -m pip install --no-cache .

.PHONY: test
test: build ## run sanity tests on the distribution
python3 -m pytest -s src/tests


11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
# infrastructure
Model to describe infrastructure
# Infrastructure as a graph

Predefined Infrastructure as a graph includes the following:

- a Generic host package
- a ZionEx host package
- a generic rack switch package
- a generic pod switch package
- tests showing how to create infrastructure
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.0.18
163 changes: 163 additions & 0 deletions protos/et_def.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
syntax = "proto3";

package ChakraProtoMsg;

message AttributeProto {
string name = 1;
string doc_string = 2;

oneof value {
double double_val = 3;
DoubleList double_list = 4;
float float_val = 5;
FloatList float_list = 6;
int32 int32_val = 7;
Int32List int32_list = 8;
int64 int64_val = 9;
Int64List int64_list = 10;
uint32 uint32_val = 11;
Uint32List uint32_list = 12;
uint64 uint64_val = 13;
Uint64List uint64_list = 14;
sint32 sint32_val = 15;
Sint32List sint32_list = 16;
sint64 sint64_val = 17;
Sint64List sint64_list = 18;
fixed32 fixed32_val = 19;
Fixed32List fixed32_list = 20;
fixed64 fixed64_val = 21;
Fixed64List fixed64_list = 22;
sfixed32 sfixed32_val = 23;
Sfixed32List sfixed32_list = 24;
sfixed64 sfixed64_val = 25;
Sfixed64List sfixed64_list = 26;
bool bool_val = 27;
BoolList bool_list = 28;
string string_val = 29;
StringList string_list = 30;
bytes bytes_val = 31;
BytesList bytes_list = 32;
}
}

message DoubleList {
repeated double values = 1;
}

message FloatList {
repeated float values = 1;
}

message Int32List {
repeated int32 values = 1;
}

message Int64List {
repeated int64 values = 1;
}

message Uint32List {
repeated uint32 values = 1;
}

message Uint64List {
repeated uint64 values = 1;
}

message Sint32List {
repeated sint32 values = 1;
}

message Sint64List {
repeated sint64 values = 1;
}

message Fixed32List {
repeated fixed32 values = 1;
}

message Fixed64List {
repeated fixed64 values = 1;
}

message Sfixed32List {
repeated sfixed32 values = 1;
}

message Sfixed64List {
repeated sfixed64 values = 1;
}

message BoolList {
repeated bool values = 1;
}

message StringList {
repeated string values = 1;
}

message BytesList {
repeated bytes values = 1;
}

message GlobalMetadata {
string version = 1;
repeated AttributeProto attr = 2;
}

enum NodeType {
INVALID_NODE = 0;
METADATA_NODE = 1;
MEM_LOAD_NODE = 2;
MEM_STORE_NODE = 3;
COMP_NODE = 4;
COMM_SEND_NODE = 5;
COMM_RECV_NODE = 6;
COMM_COLL_NODE = 7;
}

enum CollectiveCommType {
ALL_REDUCE = 0;
REDUCE = 1;
ALL_GATHER = 2;
GATHER = 3;
SCATTER = 4;
BROADCAST = 5;
ALL_TO_ALL = 6;
REDUCE_SCATTER = 7;
REDUCE_SCATTER_BLOCK = 8;
BARRIER = 9;
}

message Node {
uint64 id = 1;
string name = 2;
NodeType type = 3;

// Control and data dependencies
repeated uint64 ctrl_deps = 4;
repeated uint64 data_deps = 5;

// Timing information
uint64 start_time_micros = 6;
uint64 duration_micros = 7;

IOInfo inputs = 8;
IOInfo outputs = 9;
repeated AttributeProto attr = 10;
}

message IOInfo {
string values = 1;
string shapes = 2;
string types = 3;
}

message Tensor {
uint64 tensor_id = 1; // An unique ID for the TensorImpl object.
uint64 storage_id = 2; // An unique ID for the underlying storage object.
uint64 offset = 3; // Offset to the storage memory.
uint64 num_elem = 4; // Number of elements in the storage.
uint64 elem_bytes = 5; // Number of bytes per element.
string device = 6; // Tensor object device location.
}
Loading

0 comments on commit 258691b

Please sign in to comment.