Class FlashInferWorkspace
java.lang.Object
smile.llm.attention.FlashInferWorkspace
- All Implemented Interfaces:
AutoCloseable
Opaque FlashInfer workspace / plan handle (one per device / TP rank).
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()static FlashInferWorkspacecreate(int deviceIndex, long workspaceBytes) Allocates a workspace on the given CUDA device.handle()Returns the native workspace handle for downcalls.voidClears prefill gather caches only; decode-plan cache may remain when still valid.voidInvalidates step-scoped decode-plan and prefill-gather caches on this workspace.voidClears the cached verify-graph (SMILE_VERIFY_CUDA_GRAPH) prefill plan only.
-
Method Details
-
create
Allocates a workspace on the given CUDA device.- Parameters:
deviceIndex- CUDA device ordinal.workspaceBytes- scratch buffer size hint (0 = kernel default).- Returns:
- workspace, or
nullwhen FlashInfer is not compiled in.
-
handle
Returns the native workspace handle for downcalls.- Returns:
- native handle for downcalls.
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
invalidateRuntimeCache
public void invalidateRuntimeCache()Invalidates step-scoped decode-plan and prefill-gather caches on this workspace. Safe to call when FlashInfer is unavailable (no-op). -
invalidateVerifyRuntimeCache
public void invalidateVerifyRuntimeCache()Clears the cached verify-graph (SMILE_VERIFY_CUDA_GRAPH) prefill plan only. Must be called whenever the KV CSR tensors are rebuilt: the native plan cache's pointer-identity fast path skips comparingkv_indptrcontents, and the caching allocator routinely hands the rebuilt tensor the freed tensor's address, so without this a stale plan (old page count) is silently reused for the new, larger bucket. -
invalidatePrefillRuntimeCache
public void invalidatePrefillRuntimeCache()Clears prefill gather caches only; decode-plan cache may remain when still valid.
-