mirror of
https://github.com/deepseek-ai/DeepInfer.git
synced 2026-11-09 22:59:44 +08:00
Run DeepInfer on the native torch-neuronx device (PrivateUse1 `neuron`, torch-neuronx 2.14, no torch-xla), following the Ascend port's structure. - deep_cluster: Neuron discovery (one DeepInfer device = one logical NeuronCore, NEURON_RT_VISIBLE_CORES, NUMA from neuron-ls). - PlatformNeuron: takes the Ascend (is_npu) kernel layouts, adds is_neuron; DEEPINFER_NEURON_DEVICE=cpu runs the same code on the host for correctness work. - neuron_ops/transfer_to_neuron: map "cuda" devices, torch.device and torch.cuda.* onto neuron:0 (counterpart of torch_npu transfer_to_npu). - C++ extension: -DWITH_NEURON host-only build; torch-allocated buffers and tensor-view slot copies instead of raw device-pointer copies. - Pure-torch drop-in vendor packages (Ascend API semantics): deep_gemm, flash_mla, deep_select, tile_kernels, tilelang (constants only). - tilelang_ops/neuron backend: KV cache / metadata / norm / compress kernels; CP, ZOS and VL entry points raise NotImplementedError. - Basic mode defaults on Neuron: eager, no DSpark/MTP drafting, no zero-overhead scheduling; MoE avoids the GPU-only mega kernel; mHC prenorm GEMM uses the Ascend single-split reduction. Not yet included: deep_ep, the sampling kernels, end-to-end harness. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
25 lines
596 B
Python
25 lines
596 B
Python
"""Mirrors ``tile_kernels.rand.seed`` (DeepSeek TileKernels 2.1.0), verbatim."""
|
|
|
|
# Copyright (c) 2026 DeepSeek, MIT License (see LICENSE).
|
|
|
|
import torch
|
|
|
|
|
|
_seed = torch.initial_seed()
|
|
|
|
|
|
def set_seed(seed: int) -> None:
|
|
global _seed
|
|
torch.manual_seed(seed)
|
|
_seed = seed
|
|
|
|
|
|
def reserve_seed(num_blocks: int) -> int:
|
|
global _seed
|
|
seed = _seed
|
|
_seed += num_blocks
|
|
seed = (seed + 0x9E3779B9) & 0xFFFFFFFF
|
|
seed = ((seed ^ (seed >> 16)) * 0x21F0AAAD) & 0xFFFFFFFF
|
|
seed = ((seed ^ (seed >> 15)) * 0x735A2D97) & 0xFFFFFFFF
|
|
return (seed ^ (seed >> 15)) & 0xFFFFFFFF
|