PR13: Java Op Definitions - #10446
Open
agibsonccc wants to merge 4 commits into
Open
Conversation
Part of the 22-PR split of ag_new_release_updates_2 branch. Merge layer: 4 (java core) Files: 298 See pr-plans/00-master-plan.md for the full split plan and merge order.
This was referenced Jun 15, 2026
Contributor
Author
Architecture OverviewThis PR defines ~130 new Java Highlights
|
Add CheckpointOffloadD2H/PrefetchH2D ops, sync Conv3DDerivative/DeConv2DDerivative.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PR 13 of 22 PRs in the
ag_new_release_updates_2branch split. Merge after Layer 3 (native platform backends + DSP engine).DynamicCustomOpdefinitions for LLM/VLM inference and training; all registered inImportClassMapping(ONNX/TF) andDifferentialFunctionClassHolder(SameDiff)AutoregressiveDecode: Full decode loop as a single JNI call eliminating per-step Java↔C++ overhead; 17+ iArgs encode plan/context handles, slot indices, stop tokens; outputs:generatedTokenIds,tokenCount,timingInfo[5](totalMs, avgDecodeMs, tokPerSec, p50Ms, p99Ms)scalingas float arg;MultiLoraMatmulbatches multiple adapters for servingRmsNorm(LLaMA/Mistral semantics, no mean-centering, epsilon=1e-5),RmsNormLinear,FusedRmsNormSwiGLU,SiluAndMul,GeluAndMul,SquaredReLU,FusedLayerNormFp8Quantize/Dequantize/Matmul), AWQ fused matmul, GGML block dequantization (Q4_0/Q4_K/Q8_0), generic INT4/INT8QuantizedMatmul,SmoothQuantGpuTopKSample,GpuTopPSample,TokenSample,SamplingPenalties,TopKRenorm,TopPRenormSelectiveScan(Mamba),Mamba2SSM,GatedDeltaNetBlock,LinearAttentionDecode,EmaUpdateMixtureOfExperts,MoeGate(top-k routing),MoeSharedExperts(DeepSeek-MoE)WhisperMelSpectrogramOp(80 mel bins, 25ms window, 10ms hop — exact Whisper preprocessing),MFCC,GriffinLim, STFT, windowing functionsAdaptiveAvgPooling2D/3D,AdaptiveMaxPooling2D,DeformableConv2D,AffineGrid,GridSample,CausalConv1d,PixelShuffleMultiBackendExecutioner,BackendRoutingStrategy,KernelPluginManager,HelperRouter, routing policy hierarchy (category, data-locality, manual, performance)What Changed
Fused Attention Ops (12 new files)
FlashAttention.java/FlashAttentionBp.java— tiled IO-aware attention; Q/K/V + optional causal mask; float args: scale factorGroupedQueryAttention.java/GroupedQueryAttentionBp.java— GQA with separatenum_headsandnum_kv_heads(LLaMA3/Gemma)MLAAttention.java— Multi-head Latent Attention (DeepSeek-V3 compressed KV)CascadeAttention.java— chunked prefill / long-context decodingDecoderMaskedMha.java— decoder masked MHA with KV injectionLightningAttention.java— linear attention for efficient sequence modelingSlidingWindowAttention.java— sliding window attention (Mistral style)OnnxMultiHeadAttention.java— ONNX-compatible MHA for import pathTwoWayCrossAttention.java/TwoWayCrossAttentionBp.java— bidirectional cross-attention for VLMs (SmolDocling/SAM)PagedAttentionForward.java/PagedKvAppend.java— paged KV cache forward and slot appendingKV Cache Ops (5 files)
KVCache.java— in-place KV cache state holderKVCacheUpdate.java— updates KV cache at current position (scatter)KVCacheQuantize.java/KVCacheDequantize.java— INT8/FP8 KV quantization for memory reductionKvScatter.java/SharedKvAttention.java— scatter into paged blocks; multi-query shared KV headsPEFT Fused Linear Ops (10 files)
LoraMatMul.java/LoraMatMulBp.java—output = input @ weight + scaling * (input @ A^T @ B^T)DoraMatMul.java/DoraMatMulBp.java— weight-decomposed LoRA with per-column magnitude normalizationLohaMatMul.java/LohaMatMulBp.java— Hadamard product adaptationW + W1 ⊙ W2LokrMatMul.java/LokrMatMulBp.java— Kronecker product low-rank adaptationMultiLoraMatmul.java— batched multi-adapter LoRA for servingColumnParallelLinear.java/RowParallelLinear.java— tensor-parallel linear layers for multi-GPUNormalization and Activation Ops (12 files)
RmsNorm.java/RmsNormBp.java—x * rsqrt(mean(x^2) + eps) * gamma; no mean-centering; epsilon=1e-5 (LLaMA/Mistral)RmsNormLinear.java/RmsNormLinearBp.java— fused RMSNorm + linear projectionSkipRmsNorm.java— RMSNorm with residual skip connectionFusedRmsNormSwiGLU.java/FusedRmsNormSwiGLUBp.java— fused RMSNorm + SwiGLU gatingSiLU.java/SiLUBp.java— SiLU:x * sigmoid(x)SiluAndMul.java,GeluAndMul.java— fused SiLU/GELU + element-wise multiply (gate computation)FusedGELU.java/FusedGELUBp.java,SwishMul.java/SwishMulBp.java,SquaredReLU.java,FusedLayerNorm.java/FusedLayerNormBp.javaPositional Encoding Ops (7 files)
RoPE.java/RoPEBp.java,FusedRoPE.java/FusedRoPEBp.java— Rotary Position Embedding (LLaMA/Mistral)FusedMRoPE.java— multi-modal RoPE for VLMsDualRoPE.java— dual RoPE with per-head encodingsApplyAlibi.java— ALiBi positional biasRelativePositionBias.java— T5-style relative position biasPerLayerEmbedding.java— per-layer rotary frequency embeddingQuantization and Sampling Ops (10 files)
AwqMatmul.java— AWQ fused matmulFp8Quantize.java/Fp8Dequantize.java/Fp8Matmul.java— FP8 E4M3 (forward) / E5M2 (backward) quantization and matmulQuantizedMatmul.java— generic INT4/INT8 quantized matmul with scale and zero-pointGGMLDequantize.java— GGML block-quantized dequantization (Q4_0, Q4_K, Q8_0)SmoothQuant.java— per-channel weight/activation scaling for INT8GpuTopKSample.java/GpuTopPSample.java,TokenSample.java,SamplingPenalties.java,TopKRenorm.java/TopPRenorm.java— GPU sampling and probability renormalizationRecurrent / SSM Ops (6 files)
SelectiveScan.java— Mamba SSM selective scanMamba2SSM.java— Mamba-2 state space model recurrenceGatedDeltaNetBlock.java/GatedDeltaRule.java— Gated Delta Networks recurrent blockLinearAttentionDecode.java— linear attention decode stepEmaUpdate.java/EmaUpdateBp.java— exponential moving average updateMoE Ops (3 files)
MixtureOfExperts.java— sparse routing + expert computationMoeGate.java— top-k expert selection gating networkMoeSharedExperts.java— shared experts for DeepSeek-MoE style modelsFused Fusion Ops (8 files)
FusedElementwiseChain.java— fused chain of element-wise opsFusedBiasDropoutResidual.java— fused bias add + dropout + residualFusedGemmSwiglu.java/FusedGemmSwigluBp.java— fused GEMM + SwiGLU (single MLP kernel)FusedNormQuantize.java,SegmentGemm.java,CenterAndSharpen.java/CenterAndSharpenBp.java,VisionEmbeddingMerge.java,VisionEncodePatches.javaAutoregressive Decode Op (1 file)
AutoregressiveDecode.java— single-op decode loop; inputs: prefillEmbeddings, embeddingTable, inputIds, optional mask, posIds, KV buffers, plan external inputs; outputs:generatedTokenIds,tokenCount,timingInfo[5]Audio and Signal Processing Ops (14 files)
MelSpectrogram.java,MelFilterbank.java,MFCC.java,WhisperMelSpectrogramOp.java— Mel/MFCC extraction; Whisper: 80 mel bins, 25ms window, 10ms hopGriffinLim.java,PitchDetection.java,SpectralCentroid.java,SpectralRolloff.java,ZeroCrossingRate.java— audio feature extractionAudioNormalize.java,AudioResample.java,PreEmphasis.java,AWeighting.java,ChromaFeatures.java— audio preprocessing pipelineDFT.java,STFT.java,HannWindow.java,HammingWindow.java,BlackmanWindow.java— signal processingConvolution Extensions (7 files)
AdaptiveAvgPooling2D.java/AdaptiveAvgPooling2DBp.java,AdaptiveAvgPooling3D.java— adaptive avg pooling (output size, not kernel size)AdaptiveMaxPooling2D.java/AdaptiveMaxPooling2DBp.java— adaptive max poolingDeformableConv2D.java/config/DeformableConv2DConfig.java— deformable conv with learnable offsetsAffineGrid.java/GridSample.java— spatial transformer: affine grid + grid samplingCausalConv1d.java,PixelShuffle.java— causal 1D conv; pixel shuffle for SR upsamplingLoss Functions for Distillation (8 files)
DistillationKLLoss.java/DistillationKLLossBp.java— KL divergence for teacher/student softmaxAttentionDistillationLoss.java/AttentionDistillationLossBp.java— attention map distillationFeatureDistillationLoss.java/FeatureDistillationLossBp.java— MSE on intermediate activationsContrastiveLoss.java/ContrastiveLossBp.java— contrastive loss for embedding trainingExecutioner Infrastructure (12 files)
MultiBackendExecutioner.java/DefaultMultiBackendExecutioner.java— multi-backend op dispatch interface and defaultBackendRoutingStrategy.java/DefaultBackendRoutingStrategy.java— routing strategy for CPU/CUDA/TPUDeviceAwareOpExecutioner.java— respectsDeviceRoutingConfigurationKernelManager.java/KernelPluginManager.java/KernelSelector.java/KernelSelectionConfig.java— kernel plugin systemOpExecutionDelegator.java/TransferMetrics.java— delegating executioner wrapperHelperRouter.java/PlatformHelperDescriptor.java— platform helper routing (cuDNN, MKL, oneDNN)RoutingPolicy.java,RoutingDecision.java,CategoryBasedPolicy.java,DataLocalityPolicy.java,ManualPolicy.java,PerformancePolicy.java— routing policy hierarchyDependencies
DynamicCustomOp,BaseOp,INDArray,DataTypeAPI)Merge Order
This PR is in Layer 4 (Java op definitions — parallel with PR12, both needed before PR16).