Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
21aabb9
add feeder_v3 (reorganized feederv2, WIP)
changhai0109 Feb 14, 2025
8158a23
add weak_ptr in et_feeder_node for faster reuse (instead of lookup in…
changhai0109 Feb 17, 2025
0229f61
recover some const
changhai0109 Feb 17, 2025
ef64c60
move implementation of ETFeederNode::get_attr to header for template …
changhai0109 Feb 17, 2025
08eb9a3
clang-format, refactor typeConverter
changhai0109 Feb 17, 2025
253593b
clang-format
changhai0109 Feb 17, 2025
125a132
fixed bugs, add dirty flag for dependancy solver, add tests, add grap…
changhai0109 Feb 18, 2025
827d9a0
bugfix: conditional generation of cvt template in order to avoid unsu…
changhai0109 Feb 20, 2025
38b2a6c
separate et_feeder_node_attr header
changhai0109 Feb 20, 2025
0cce9a4
add inputs/outputs getter
changhai0109 Feb 20, 2025
fece597
add interface of get ongoing nodes
changhai0109 Feb 20, 2025
f37c2bb
feederv3
changhai0109 Apr 17, 2025
7b5a1b4
Update README.md
TheKanter Jun 18, 2025
bdf6177
Merge pull request #199 from mlcommons/TheKanter-patch-1
tushar-krishna Aug 1, 2025
6dc587c
Update protobuf dependency to use most recent version
jinsun-yoo Aug 8, 2025
90630ca
add alies of Feeder == FeederV3::Feeder
changhai0109 Aug 11, 2025
0e3cd40
expose feeder_id, add helper function to complain for non-exist attr …
changhai0109 Aug 14, 2025
7d11c3c
Merge pull request #202 from astra-sim/protobuf_version
tushar-krishna Sep 24, 2025
277ba61
Default num_ops_ to 0
Sep 9, 2025
3109b13
Merge pull request #204 from przemekbary/przemekbary_numops_fix
tushar-krishna Sep 25, 2025
ec41090
Replace distutils with setuptools in setup (#206)
Srinidhi2000 Oct 23, 2025
177ad6c
add soft sanity check: only warn if graph has problem
changhai0109 Oct 24, 2025
c353a55
hotfix for real traces
changhai0109 Oct 24, 2025
51c8b99
update
changhai0109 Mar 12, 2026
96ec725
Merge pull request #1 from imec-int/mlcommons_cherry_pick
Mekapaedia Mar 26, 2026
bc43d1c
Merge pull request #2 from imec-int/changhai/chakra_paper
Mekapaedia Mar 26, 2026
cd3661e
Make heavier non-core dependencies optional
Mekapaedia Mar 12, 2026
d6cd0e5
Merge pull request #3 from imec-int/optional_deps
Mekapaedia Mar 26, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Chakra is an open and interoperable graph-based representation of AI/ML workload

This is a repository of Chakra schema and a complementary set of tools and capabilities to enable the collection, analysis, generation, and adoption of Chakra execution traces by a broad range of simulators, emulators, and replay tools.

Chakra is under active development as a [MLCommons](https://mlcommons.org/en) research project. Please see [MLCommons Chakra Working Group](https://mlcommons.org/en/groups/research-chakratracebench/) for more details for participating in this effort.
Chakra is under active development as a [MLCommons](https://mlcommons.org/en)® research project. Please see [MLCommons Chakra Working Group](https://mlcommons.org/en/groups/research-chakratracebench/) for more details for participating in this effort.

A detailed description of the original motivation and guiding principles can be found [here](https://arxiv.org/abs/2305.14516). The paper was published prior to Chakra becoming a MLCommons project. Please cite this repository to refer to the latest Chakra schema and tools.

Expand Down
15 changes: 12 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
[build-system]
requires = ["setuptools", "setuptools-grpc"]
requires = [ "setuptools>=61",
"wheel",
"setuptools-grpc",
"grpcio-tools"]
build-backend = "setuptools.build_meta"

[project]
Expand All @@ -12,10 +15,16 @@ authors = [
{name = "MLCommons", email = "chakra@mlcommons.org"},
]
dependencies = [
"protobuf==5.*",
"protobuf"
]

[project.optional-dependencies]
visualizer = [
"graphviz",
"networkx",
"pydot",
"pydot"
]
trace_link = [
"HolisticTraceAnalysis @ git+https://github.com/facebookresearch/HolisticTraceAnalysis.git@d731cc2e2249976c97129d409a83bd53d93051f6"
]

Expand Down
4 changes: 1 addition & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from distutils.command.build import build

from setuptools import setup

from setuptools.command.build import build

class build_grpc(build):
"""
Expand Down
5 changes: 1 addition & 4 deletions src/feeder/et_feeder.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@
#include "protoio.hh"

namespace Chakra {
struct CompareNodes : public std::binary_function<
std::shared_ptr<ETFeederNode>,
std::shared_ptr<ETFeederNode>,
bool> {
struct CompareNodes {
bool operator()(
const std::shared_ptr<ETFeederNode> lhs,
const std::shared_ptr<ETFeederNode> rhs) const {
Expand Down
1 change: 1 addition & 0 deletions src/feeder/et_feeder_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ ETFeederNode::ETFeederNode(std::shared_ptr<ChakraProtoMsg::Node> node) {
this->name_ = node->name();
this->runtime_ = node->duration_micros();
this->is_cpu_op_ = 0;
this->num_ops_ = 0;

if (node->has_inputs()) {
this->inputs_values_ = static_cast<string>(node->inputs().values());
Expand Down
101 changes: 101 additions & 0 deletions src/feeder_v3/cache.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
#ifndef CHAKRA_FEEDER_V3_CACHE_H
#define CHAKRA_FEEDER_V3_CACHE_H

#include <list>
#include <memory>
#include <mutex>
#include <shared_mutex>
#include <unordered_map>

namespace Chakra {
namespace FeederV3 {

template <typename K, typename V>
class Cache {
public:
Cache(size_t capacity) : capacity(capacity) {}
void put(const K& key, const V& value) {
std::unique_lock lock(cache_mutex);
if (this->cache.find(key) != this->cache.end()) {
// hit and update
this->lru.erase(this->cache[key].second);
this->lru.push_back(key);
this->cache[key].second = --this->lru.end();
this->cache[key].first = std::make_shared<V>(value);
} else {
// miss
while (this->cache.size() >= this->capacity) {
// evict
auto victim = this->lru.front();
this->cache.erase(victim);
this->lru.pop_front();
}
// and put new
this->lru.push_back(key);
this->cache[key] =
std::make_pair(std::make_shared<V>(value), --this->lru.end());
}
}
bool has(const K& key) {
std::shared_lock lock(cache_mutex);
return this->cache.find(key) != this->cache.end();
}
std::weak_ptr<const V> get(const K& key) {
std::shared_lock lock(cache_mutex);
if (this->cache.find(key) == this->cache.end()) {
throw std::runtime_error("Key not found in cache");
}
std::weak_ptr<const V> value(this->cache.at(key).first);
return value;
}
std::shared_ptr<const V> get_locked(const K& key) {
std::shared_lock lock(cache_mutex);
if (this->cache.find(key) == this->cache.end()) {
throw std::runtime_error("Key not found in cache");
}
return this->cache.at(key).first;
}
std::weak_ptr<const V> get_or_null(const K& key) {
std::shared_lock lock(cache_mutex);
if (this->cache.find(key) == this->cache.end()) {
return std::weak_ptr<V>();
}
std::weak_ptr<const V> value(this->cache.at(key).first);
return value;
}
std::shared_ptr<const V> get_or_null_locked(const K& key) {
std::shared_lock lock(cache_mutex);
if (this->cache.find(key) == this->cache.end()) {
return std::shared_ptr<const V>();
}
return this->cache.at(key).first;
}

void remove(const K& key) {
std::unique_lock lock(cache_mutex);
if (this->cache.find(key) == this->cache.end()) {
throw std::runtime_error("Key not found in cache");
}
this->lru.erase(this->cache[key].second);
this->cache.erase(key);
}

~Cache() {
this->cache.clear();
this->lru.clear();
}

private:
size_t capacity;
std::unordered_map<
K,
std::pair<std::shared_ptr<V>, typename std::list<K>::iterator>>
cache;
std::list<K> lru;
mutable std::shared_mutex cache_mutex;
};

} // namespace FeederV3
} // namespace Chakra

#endif
32 changes: 32 additions & 0 deletions src/feeder_v3/common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#ifndef CHAKRA_FEEDER_V3_COMMON_H
#define CHAKRA_FEEDER_V3_COMMON_H
#include <cstdint>
#include "et_def.pb.h"

namespace Chakra {
namespace FeederV3 {
using NodeId = uint64_t;
using ETFeederId = uint64_t;
using ChakraNode = ChakraProtoMsg::Node;
using ChakraGlobalMetadata = ChakraProtoMsg::GlobalMetadata;
using ChakraAttr = ChakraProtoMsg::AttributeProto;

constexpr static bool ALLOW_IMPLICIT_INTEGER_CONVERSION = true;
constexpr static bool ALLOW_IMPLICIT_FLOAT_CONVERSION = true;
constexpr static bool ALLOW_IMPLICIT_INTEGER_TO_FLOAT_CONVERSION = true;
constexpr static bool ALLOW_IMPLICIT_FLOAT_TO_INTEGER_CONVERSION = false;
constexpr static bool NO_IMPLICIT_CONVERSION = false;
constexpr static bool DEFAULT_STRICT_TYPING = false;

constexpr static size_t DEFAULT_ETFEEDER_CACHE_SIZE = 16384;
constexpr static bool RESOLVE_DATA_DEPS = true;
constexpr static bool RESOLVE_CTRL_DEPS = false;

constexpr static size_t DEFAULT_PROTOBUF_BUFFER_SIZE = 16384;

constexpr static bool SOFT_SANITY_CHECK = true;

} // namespace FeederV3
} // namespace Chakra

#endif
Loading