Skip to content

Instantly share code, notes, and snippets.

View nirandaperera's full-sized avatar

Niranda Perera nirandaperera

View GitHub Profile
# SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES.
# SPDX-License-Identifier: Apache-2.0
"""
Concurrency smoke test for the streaming actor network.
Runs 2 Python delay actors concurrently in a
single ``run_actor_network`` call. Each actor sleeps for ``sleep_seconds``
and is wrapped in an NVTX range so the layout is visible under Nsight
Systems.

Detailed Design Summary: Memory Reservations and Memory Spaces

Sirius Project - Memory Management Architecture


Overview

The Sirius project implements a sophisticated hierarchical memory management system designed to coordinate memory allocations across multiple memory tiers (GPU, Host, and Disk). The design centers around two core abstractions:

@nirandaperera
nirandaperera / r1-response.md
Created March 4, 2025 18:34
deep seek wrong response

In Python, abstract methods can have default implementations, but this is not the typical use case for abstract methods. Abstract methods are usually defined in abstract base classes (ABCs) to enforce that subclasses must implement them. However, Python's flexibility allows you to provide a default implementation if needed.

Here’s how you can do it:

Using abc Module

The abc module in Python provides the ABC class and the abstractmethod decorator to define abstract methods. By default, abstract methods do not have implementations, but you can provide a default implementation in the abstract base class.

from abc import ABC, abstractmethod
@nirandaperera
nirandaperera / collective_api.hpp
Created December 21, 2023 20:26
Collective API
//
// Created by niranda on 12/12/23.
//
#pragma once
#include <cstdint>
#include <memory>
#include <future>
#include <arrow/api.h>
//
// Created by nira on 5/21/20.
//
#ifndef TWISTERX_CPP_SRC_TWISTERX_ARROW_ARROW_HASH_KERNELS_HPP_
#define TWISTERX_CPP_SRC_TWISTERX_ARROW_ARROW_HASH_KERNELS_HPP_
#include <arrow/api.h>
#include <arrow/compute/kernel.h>
#include <glog/logging.h>
#!/bin/bash
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
engine = 'ray' # 'dask'
w = 128 # 1 .. 512
r = 10**6
it = 4
rng = default_rng()
frame_data = rng.integers(0, r, size=(r, 2))
val = np.random.randint(0, r)
@nirandaperera
nirandaperera / serde_table.cpp
Created December 8, 2021 22:53
serialize and deserialize arrow record batches
#include <arrow/ipc/api.h>
#include <arrow/io/api.h>
TEST_CASE(""){
auto schema = arrow::schema({
{field("a", arrow::utf8())},
{field("b", arrow::large_utf8())},
});
/**
* ref:
* created by the following script
for k in range(256):
x = 0
for i in range(8):
x+= ((k>>i)&1)<<(8*i)
print(hex(x))
*/
static constexpr uint64_t bits_to_ulong[] =
@nirandaperera
nirandaperera / variant_comp.cpp
Last active October 5, 2021 01:22
variant static polimorph comparators
#include <iostream>
#include <variant>
#include <vector>
struct EqualToI {
EqualToI(const int *data_1, const int *data_2) : data1(data_1), data2(data_2) {}
const int *data1, *data2;
bool operator()(size_t i, size_t j) const {
return std::equal_to<>()(data1[i], data2[j]);
}