Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 3rdparty/tvm
Submodule tvm updated 71 files
+1 −1 3rdparty/tvm-ffi
+6 −0 include/tvm/ir/name_supply.h
+2 −0 include/tvm/meta_schedule/database.h
+4 −1 include/tvm/meta_schedule/feature_extractor.h
+4 −1 include/tvm/meta_schedule/measure_callback.h
+2 −1 include/tvm/meta_schedule/mutator.h
+4 −1 include/tvm/meta_schedule/postproc.h
+2 −2 include/tvm/meta_schedule/profiler.h
+9 −0 include/tvm/meta_schedule/runner.h
+4 −1 include/tvm/meta_schedule/schedule_rule.h
+2 −0 include/tvm/meta_schedule/search_strategy.h
+2 −0 include/tvm/meta_schedule/space_generator.h
+9 −1 include/tvm/relax/nested_msg.h
+4 −0 include/tvm/runtime/data_type.h
+1 −0 include/tvm/runtime/tensor.h
+2 −1 include/tvm/tir/block_scope.h
+4 −2 include/tvm/tir/schedule/schedule.h
+0 −15 python/tvm/te/tensor.py
+3 −0 python/tvm/testing/_ffi_api.py
+58 −1 src/arith/const_int_bound.cc
+56 −20 src/arith/int_set.cc
+1 −0 src/arith/presburger_set.cc
+0 −7 src/arith/rewrite_simplify.cc
+1 −0 src/ir/name_supply.cc
+7 −0 src/meta_schedule/measure_callback/add_to_database.cc
+7 −0 src/meta_schedule/measure_callback/remove_build_artifact.cc
+7 −0 src/meta_schedule/measure_callback/update_cost_model.cc
+7 −0 src/meta_schedule/postproc/disallow_async_strided_mem_copy.cc
+7 −0 src/meta_schedule/postproc/disallow_dynamic_loop.cc
+1 −0 src/meta_schedule/postproc/rewrite_cooperative_fetch.cc
+7 −0 src/meta_schedule/postproc/rewrite_layout.cc
+7 −0 src/meta_schedule/postproc/rewrite_parallel_vectorize_unroll.cc
+2 −2 src/meta_schedule/postproc/rewrite_reduction_block.cc
+2 −2 src/meta_schedule/postproc/rewrite_tensorize.cc
+7 −0 src/meta_schedule/postproc/verify_gpu_code.cc
+7 −0 src/meta_schedule/postproc/verify_vtcm_limit.cc
+1 −0 src/meta_schedule/runner/runner.cc
+14 −0 src/meta_schedule/schedule_rule/multi_level_tiling_tensor_core.cc
+7 −0 src/meta_schedule/schedule_rule/multi_level_tiling_wide_vector.cc
+6 −0 src/meta_schedule/schedule_rule/multi_level_tiling_with_intrin.cc
+2 −1 src/meta_schedule/search_strategy/replay_func.cc
+2 −1 src/meta_schedule/space_generator/post_order_apply.cc
+4 −2 src/meta_schedule/space_generator/schedule_fn.cc
+1 −0 src/relax/ir/block_builder.cc
+1 −0 src/relax/ir/py_expr_functor.cc
+1 −1 src/relax/transform/fold_constant.cc
+5 −4 src/runtime/contrib/random/mt_random_engine.cc
+1 −0 src/runtime/disco/distributed/socket_session.cc
+1 −0 src/runtime/disco/process_session.cc
+2 −0 src/runtime/disco/session.cc
+6 −0 src/runtime/disco/threaded_session.cc
+3 −0 src/runtime/profiling.cc
+3 −0 src/runtime/rpc/rpc_session.cc
+1 −1 src/runtime/vm/builtin.cc
+4 −2 src/tir/ir/py_functor.cc
+2 −1 src/tir/schedule/concrete_schedule.h
+2 −0 src/tir/schedule/schedule.cc
+2 −1 src/tir/schedule/traced_schedule.h
+12 −0 tests/python/arith/test_arith_const_int_bound.py
+10 −0 tests/python/arith/test_arith_intset.py
+12 −0 tests/python/arith/test_arith_simplify.py
+44 −44 tests/python/meta_schedule/test_meta_schedule_feature_extractor_per_store_feature.py
+3 −1 tests/python/relax/test_codegen_cudnn.py
+1 −1 tests/python/relax/test_op_create.py
+145 −151 tests/python/relax/test_transform_legalize_ops_nn.py
+2 −2 tests/python/relax/test_transform_legalize_ops_qdq.py
+7 −7 tests/python/relax/test_transform_legalize_ops_search_statistical.py
+2 −2 tests/python/te/test_te_create_primfunc.py
+2 −1 tests/python/tir-base/test_tir_ptx_cp_async.py
+1 −1 tests/python/tir-transform/test_tir_transform_inject_ptx_async_copy.py
+1 −1 web/emcc/wasm_runtime.cc
5 changes: 5 additions & 0 deletions cpp/serve/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ namespace mlc {
namespace llm {
namespace serve {

TVM_FFI_STATIC_INIT_BLOCK() {
GenerationConfigNode::RegisterReflection();
EngineConfigNode::RegisterReflection();
}

uint64_t TotalDetectGlobalMemory(DLDevice device) {
// Get single-card GPU size.
tvm::ffi::Any rv;
Expand Down
11 changes: 11 additions & 0 deletions cpp/serve/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <picojson.h>
#include <tvm/ffi/container/array.h>
#include <tvm/ffi/reflection/registry.h>
#include <tvm/ffi/string.h>
#include <tvm/runtime/device_api.h>
#include <tvm/runtime/int_tuple.h>
Expand Down Expand Up @@ -135,6 +136,11 @@ class GenerationConfigNode : public Object {

picojson::object AsJSON() const;

static void RegisterReflection() {
namespace refl = tvm::ffi::reflection;
refl::ObjectDef<GenerationConfigNode>();
}

static constexpr const bool _type_has_method_sequal_reduce = false;
static constexpr const bool _type_has_method_shash_reduce = false;
TVM_FFI_DECLARE_OBJECT_INFO("mlc.serve.GenerationConfig", GenerationConfigNode, Object);
Expand Down Expand Up @@ -302,6 +308,11 @@ class EngineConfigNode : public Object {

String AsJSONString() const;

static void RegisterReflection() {
namespace refl = tvm::ffi::reflection;
refl::ObjectDef<EngineConfigNode>();
}

static constexpr const bool _type_has_method_sequal_reduce = false;
static constexpr const bool _type_has_method_shash_reduce = false;
static constexpr const bool _type_mutable = true;
Expand Down
8 changes: 8 additions & 0 deletions cpp/serve/data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ namespace mlc {
namespace llm {
namespace serve {

TVM_FFI_STATIC_INIT_BLOCK() {
DataNode::RegisterReflection();
TextDataNode::RegisterReflection();
TokenDataNode::RegisterReflection();
ImageDataNode::RegisterReflection();
RequestStreamOutputObj::RegisterReflection();
}

/****************** Data ******************/

std::pair<Array<Data>, Array<Data>> SplitData(const Array<Data>& original_data, int total_length,
Expand Down
33 changes: 30 additions & 3 deletions cpp/serve/data.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <tvm/ffi/container/array.h>
#include <tvm/ffi/container/shape.h>
#include <tvm/ffi/optional.h>
#include <tvm/ffi/reflection/registry.h>
#include <tvm/ffi/string.h>
#include <tvm/node/cast.h>
#include <tvm/runtime/int_tuple.h>
Expand Down Expand Up @@ -50,8 +51,14 @@ class DataNode : public Object {
*/
virtual ObjectRef GetEmbedding(Model model, ObjectRef* dst = nullptr, int offset = 0) const = 0;

static void RegisterReflection() {
namespace refl = tvm::ffi::reflection;
refl::ObjectDef<DataNode>();
}

static constexpr const bool _type_has_method_sequal_reduce = false;
static constexpr const bool _type_has_method_shash_reduce = false;
static constexpr const uint32_t _type_child_slots = 3;
TVM_FFI_DECLARE_OBJECT_INFO("mlc.serve.Data", DataNode, Object);
};

Expand All @@ -75,7 +82,12 @@ class TextDataNode : public DataNode {
int GetLength() const final;
ObjectRef GetEmbedding(Model model, ObjectRef* dst = nullptr, int offset = 0) const final;

TVM_FFI_DECLARE_OBJECT_INFO("mlc.serve.TextData", TextDataNode, DataNode);
static void RegisterReflection() {
namespace refl = tvm::ffi::reflection;
refl::ObjectDef<TextDataNode>();
}

TVM_FFI_DECLARE_OBJECT_INFO_FINAL("mlc.serve.TextData", TextDataNode, DataNode);
};

class TextData : public Data {
Expand All @@ -96,7 +108,12 @@ class TokenDataNode : public DataNode {
int GetLength() const final;
ObjectRef GetEmbedding(Model model, ObjectRef* dst = nullptr, int offset = 0) const final;

TVM_FFI_DECLARE_OBJECT_INFO("mlc.serve.TokenData", TokenDataNode, DataNode);
static void RegisterReflection() {
namespace refl = tvm::ffi::reflection;
refl::ObjectDef<TokenDataNode>();
}

TVM_FFI_DECLARE_OBJECT_INFO_FINAL("mlc.serve.TokenData", TokenDataNode, DataNode);
};

class TokenData : public Data {
Expand All @@ -120,7 +137,12 @@ class ImageDataNode : public DataNode {
int GetLength() const final;
ObjectRef GetEmbedding(Model model, ObjectRef* dst = nullptr, int offset = 0) const final;

TVM_FFI_DECLARE_OBJECT_INFO("mlc.serve.ImageData", ImageDataNode, DataNode);
static void RegisterReflection() {
namespace refl = tvm::ffi::reflection;
refl::ObjectDef<ImageDataNode>();
}

TVM_FFI_DECLARE_OBJECT_INFO_FINAL("mlc.serve.ImageData", ImageDataNode, DataNode);
};

class ImageData : public Data {
Expand Down Expand Up @@ -197,6 +219,11 @@ class RequestStreamOutputObj : public Object {

std::atomic<bool> unpacked = false;

static void RegisterReflection() {
namespace refl = tvm::ffi::reflection;
refl::ObjectDef<RequestStreamOutputObj>();
}

static constexpr const bool _type_has_method_sequal_reduce = false;
static constexpr const bool _type_has_method_shash_reduce = false;
static constexpr const bool _type_mutable = true;
Expand Down
2 changes: 2 additions & 0 deletions cpp/serve/draft_token_workspace_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ namespace mlc {
namespace llm {
namespace serve {

TVM_FFI_STATIC_INIT_BLOCK() { DraftTokenWorkspaceManagerObj::RegisterReflection(); }

DraftTokenWorkspaceManagerObj::DraftTokenWorkspaceManagerObj(int max_num_tokens, int vocab_size,
int hidden_size,
DLDataType hidden_states_dtype,
Expand Down
6 changes: 6 additions & 0 deletions cpp/serve/draft_token_workspace_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#ifndef MLC_LLM_SERVE_DRAFT_TOKEN_WORKSPACE_MANAGER_H_
#define MLC_LLM_SERVE_DRAFT_TOKEN_WORKSPACE_MANAGER_H_
#include <tvm/ffi/reflection/registry.h>
#include <tvm/runtime/device_api.h>

#include <numeric>
Expand Down Expand Up @@ -73,6 +74,11 @@ class DraftTokenWorkspaceManagerObj : public Object {
*/
void FreeSlots(const std::vector<int>& slots);

static void RegisterReflection() {
namespace refl = tvm::ffi::reflection;
refl::ObjectDef<DraftTokenWorkspaceManagerObj>();
}

static constexpr const bool _type_has_method_sequal_reduce = false;
static constexpr const bool _type_has_method_shash_reduce = false;
static constexpr const bool _type_mutable = true;
Expand Down
6 changes: 5 additions & 1 deletion cpp/serve/engine_actions/action.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@

namespace mlc {
namespace llm {
namespace serve {} // namespace serve
namespace serve {

TVM_FFI_STATIC_INIT_BLOCK() { EngineActionObj::RegisterReflection(); }

} // namespace serve
} // namespace llm
} // namespace mlc
5 changes: 5 additions & 0 deletions cpp/serve/engine_actions/action.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ class EngineActionObj : public Object {
*/
virtual Array<Request> Step(EngineState estate) = 0;

static void RegisterReflection() {
namespace refl = tvm::ffi::reflection;
refl::ObjectDef<EngineActionObj>();
}

static constexpr const bool _type_has_method_sequal_reduce = false;
static constexpr const bool _type_has_method_shash_reduce = false;
static constexpr const bool _type_mutable = true;
Expand Down
2 changes: 2 additions & 0 deletions cpp/serve/engine_state.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ namespace mlc {
namespace llm {
namespace serve {

TVM_FFI_STATIC_INIT_BLOCK() { EngineStateObj::RegisterReflection(); }

EngineState::EngineState() { data_ = tvm::ffi::make_object<EngineStateObj>(); }

void EngineStateObj::Reset() {
Expand Down
5 changes: 5 additions & 0 deletions cpp/serve/engine_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ class EngineStateObj : public Object {
/*! \brief Return the running request state entries*/
const std::vector<RequestStateEntry>& GetRunningRequestStateEntries();

static void RegisterReflection() {
namespace refl = tvm::ffi::reflection;
refl::ObjectDef<EngineStateObj>();
}

static constexpr const bool _type_has_method_sequal_reduce = false;
static constexpr const bool _type_has_method_shash_reduce = false;
static constexpr const bool _type_mutable = true;
Expand Down
1 change: 1 addition & 0 deletions cpp/serve/event_trace_recorder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ EventTraceRecorder EventTraceRecorder::Create() {

TVM_FFI_STATIC_INIT_BLOCK() {
namespace refl = tvm::ffi::reflection;
EventTraceRecorderImpl::RegisterReflection();
refl::GlobalDef()
.def("mlc.serve.EventTraceRecorder", []() { return EventTraceRecorder::Create(); })
.def("mlc.serve.EventTraceRecorderAddEvent",
Expand Down
6 changes: 6 additions & 0 deletions cpp/serve/event_trace_recorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#define MLC_LLM_SERVE_EVENT_TRACE_RECORDER_H_

#include <tvm/ffi/container/array.h>
#include <tvm/ffi/reflection/registry.h>
#include <tvm/ffi/string.h>
#include <tvm/runtime/object.h>

Expand Down Expand Up @@ -41,6 +42,11 @@ class EventTraceRecorderObj : public Object {
/*! \brief Dump the logged events in Chrome Trace Event Format in JSON string. */
virtual std::string DumpJSON() = 0;

static void RegisterReflection() {
namespace refl = tvm::ffi::reflection;
refl::ObjectDef<EventTraceRecorderObj>();
}

static constexpr const bool _type_has_method_sequal_reduce = false;
static constexpr const bool _type_has_method_shash_reduce = false;
static constexpr const bool _type_mutable = true;
Expand Down
2 changes: 2 additions & 0 deletions cpp/serve/logit_processor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ inline void SyncCopyStream(Device device, TVMStreamHandle compute_stream,

/***************** LogitProcessor Implementation *****************/

TVM_FFI_STATIC_INIT_BLOCK() { LogitProcessorObj::RegisterReflection(); }

class LogitProcessorImpl : public LogitProcessorObj {
public:
/*! * \brief Constructor of LogitProcessorImpl. */
Expand Down
5 changes: 5 additions & 0 deletions cpp/serve/logit_processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ class LogitProcessorObj : public Object {
const Array<String>& request_ids,
const std::vector<int>* cum_num_token = nullptr) = 0;

static void RegisterReflection() {
namespace refl = tvm::ffi::reflection;
refl::ObjectDef<LogitProcessorObj>();
}

static constexpr const bool _type_has_method_sequal_reduce = false;
static constexpr const bool _type_has_method_shash_reduce = false;
static constexpr const bool _type_mutable = true;
Expand Down
2 changes: 2 additions & 0 deletions cpp/serve/model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ namespace serve {

/*********************** Model Implementation ***********************/

TVM_FFI_STATIC_INIT_BLOCK() { ModelObj::RegisterReflection(); }

class ModelImpl;

Model Model::Create(String reload_lib_path, String model_path, const picojson::object& model_config,
Expand Down
5 changes: 5 additions & 0 deletions cpp/serve/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,11 @@ class ModelObj : public Object {
/*! \brief Call the given global function on all workers. Only for debug purpose. */
virtual void DebugCallFuncOnAllAllWorker(const String& func_name, Optional<String> func_args) = 0;

static void RegisterReflection() {
namespace refl = tvm::ffi::reflection;
refl::ObjectDef<ModelObj>();
}

static constexpr const bool _type_has_method_sequal_reduce = false;
static constexpr const bool _type_has_method_shash_reduce = false;
static constexpr const bool _type_mutable = true;
Expand Down
2 changes: 2 additions & 0 deletions cpp/serve/prefix_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ namespace serve {

using namespace tvm::runtime;

TVM_FFI_STATIC_INIT_BLOCK() { PrefixCacheObj::RegisterReflection(); }

/*!
* \brief The implementation of prefix cache.
*/
Expand Down
6 changes: 6 additions & 0 deletions cpp/serve/prefix_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#ifndef MLC_LLM_SERVE_PREFIX_CACHE_H_
#define MLC_LLM_SERVE_PREFIX_CACHE_H_
#include <tvm/ffi/container/shape.h>
#include <tvm/ffi/reflection/registry.h>
#include <tvm/runtime/object.h>

#include <functional>
Expand Down Expand Up @@ -122,6 +123,11 @@ class PrefixCacheObj : public Object {
/*! \brief Return the prefix cache mode. */
virtual PrefixCacheMode Mode() = 0;

static void RegisterReflection() {
namespace refl = tvm::ffi::reflection;
refl::ObjectDef<PrefixCacheObj>();
}

static constexpr const bool _type_mutable = true;
TVM_FFI_DECLARE_OBJECT_INFO("mlc.serve.PrefixCache", PrefixCacheObj, Object);
};
Expand Down
2 changes: 2 additions & 0 deletions cpp/serve/radix_tree.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ namespace serve {

using namespace tvm::runtime;

TVM_FFI_STATIC_INIT_BLOCK() { PagedRadixTreeObj::RegisterReflection(); }

/*!
* \brief The sequence ID linked list structure in paged radix tree node.
*/
Expand Down
6 changes: 6 additions & 0 deletions cpp/serve/radix_tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#ifndef MLC_LLM_SERVE_RADIX_TREE_H_
#define MLC_LLM_SERVE_RADIX_TREE_H_
#include <tvm/ffi/container/shape.h>
#include <tvm/ffi/reflection/registry.h>
#include <tvm/runtime/int_tuple.h>
#include <tvm/runtime/object.h>

Expand Down Expand Up @@ -107,6 +108,11 @@ class PagedRadixTreeObj : public Object {
*/
virtual void Reset() = 0;

static void RegisterReflection() {
namespace refl = tvm::ffi::reflection;
refl::ObjectDef<PagedRadixTreeObj>();
}

static constexpr const bool _type_mutable = true;
TVM_FFI_DECLARE_OBJECT_INFO("mlc.serve.PagedRadixTree", PagedRadixTreeObj, Object);
};
Expand Down
2 changes: 2 additions & 0 deletions cpp/serve/request.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ namespace serve {

/****************** Request ******************/

TVM_FFI_STATIC_INIT_BLOCK() { RequestNode::RegisterReflection(); }

Request::Request(String id, Array<Data> inputs, GenerationConfig generation_cfg) {
if (generation_cfg->debug_config.special_request == SpecialRequestKind::kNone) {
CHECK(!inputs.empty()) << "No input data is given.";
Expand Down
6 changes: 6 additions & 0 deletions cpp/serve/request.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#define MLC_LLM_SERVE_REQUEST_H_

#include <tvm/ffi/container/array.h>
#include <tvm/ffi/reflection/registry.h>
#include <tvm/ffi/string.h>
#include <tvm/runtime/object.h>

Expand Down Expand Up @@ -55,6 +56,11 @@ class RequestNode : public Object {
/*! \brief Backward reference to the request state. */
Object* rstate = nullptr;

static void RegisterReflection() {
namespace refl = tvm::ffi::reflection;
refl::ObjectDef<RequestNode>();
}

static constexpr const bool _type_has_method_sequal_reduce = false;
static constexpr const bool _type_has_method_shash_reduce = false;
static constexpr const bool _type_mutable = true;
Expand Down
6 changes: 6 additions & 0 deletions cpp/serve/request_state.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ namespace mlc {
namespace llm {
namespace serve {

TVM_FFI_STATIC_INIT_BLOCK() {
RequestModelStateNode::RegisterReflection();
RequestStateEntryNode::RegisterReflection();
RequestStateNode::RegisterReflection();
}

/****************** RequestModelState ******************/

RequestModelState::RequestModelState(
Expand Down
Loading
Loading