PR12: ND4J Java API & Core Infrastructure#10445
Open
agibsonccc wants to merge 13 commits into
Open
Conversation
Part of the 22-PR split of ag_new_release_updates_2 branch. Merge layer: 4 (java core) Files: 290 See pr-plans/00-master-plan.md for the full split plan and merge order.
…-core # Conflicts: # nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/shape/LongShapeDescriptor.java
This was referenced Jun 15, 2026
…DifferentialFunctionClassHolder.java
OnnxExporter and OnnxExportConfig are pure stubs — every method throws UnsupportedOperationException and nothing in the codebase references them. Delete both files rather than shipping dead API surface. In MmulHelper.cpp, upgrade the silent comment acknowledging a known bug in mmulNxN batch index calculation to a prominent WARNING + TODO so the workaround path is discoverable and the root cause is not forgotten.
…ion code Cherry-picked nd4j-profiler, nd4j-common, and nd4j-common-tests changes from 2fdeaa4 — switches logging/error handling off raw println.
- AttentionFusionOptimizations: remove 17 [ATTN-DIAG*] println calls that fired on every optimization pass (log.debug equivalents exist) - Permute.doDiff(): convert 3 println to log.debug - Enter: delete bare empty println() in constructor - UnsortedSegmentSum: delete bare empty println() in constructor - OpExclusionUtils: convert println/err to slf4j log.debug/warn
Delete 24 commented-out case entries after the default throw in pairwiseOpClass that were unreachable dead code.
Contributor
Author
Architecture OverviewThis PR builds the ND4J Java API and core infrastructure that all higher-level Java modules depend on. It introduces the multi-device abstraction layer ( Highlights
|
…lVersionUID, slf4j, property centralization - ArrayUtil god class → ArrayTypeConverters + ArrayMathUtils extractions - AbstractSession god class → SessionExecutionDiagnostics extraction - ND4JSystemProperties: 11 new centralized property constants - serialVersionUID additions across evaluation, config, dataset classes - System.out.println → slf4j logging migration - Deprecated boxed constructors → valueOf/autobox
Apply Java compilation fixes for ND4J API core files.
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 12 of 22 PRs in the
ag_new_release_updates_2branch split. Merge after Layer 3 (native platform backends + DSP engine).DeviceMemoryManagersingleton with per-deviceAtomicLongcounters,ReentrantReadWriteLockcap enforcement,selectDeviceForAllocation(bytes)sorted by priority then free memoryDeviceDescriptorinterface →CudaDeviceDescriptor,CpuDeviceDescriptor,StubDeviceDescriptor;StubDeviceContextProviderenables full multi-GPU topology simulation in tests without hardwareorg/nd4j/linalg/framework/; completely lazy tree viaNd4j.framework.execution()/.memory()/.device()/.workspaces()/.profiling()/.lifecycle()/.diagnostics(); costs nothing if unusedHybridDataBuffertracksCoherenceState(HOST_ONLY/DEVICE_ONLY/SYNCHRONIZED);syncToHost()/syncToDevice()are no-ops when state already valid — eliminates redundant H2D/D2H transfersNd4j.graphScope()returns aGraphScopethat tracesGraphFunctioncalls into a hidden SameDiff graph;LazyINDArrayproxy trackssdVariableNameduring tracing while blocking data access;CompiledGraphFunctionis the cached resultDspEnvironmentConfig,TritonEnvironmentConfig, and others consolidate scatteredSystem.getProperty("nd4j.dsp.*")calls into typed@BuilderclassesBackendManager+BackendRegistryreplace ad-hocServiceLoadercalls; plugin-based native ops loading viaNativePluginLoaderWhat Changed
Device Abstraction Layer (10 files)
DeviceMemoryManager.java— singleton: per-deviceAtomicLongcounters, memory caps,selectDeviceForAllocation(),configureStubTopology()for test stubsDeviceDescriptor.java— device identity interface (key in all device maps)CudaDeviceDescriptor.java,CpuDeviceDescriptor.java,BaseDeviceDescriptor.java— concrete descriptors with device type and indexDeviceContextProvider.java,DeviceContext.java— device-switching with stream handle managementStubDeviceDescriptor.java,StubDeviceContextProvider.java— test stubs for multi-GPU simulation without hardwareDeviceRoutingConfiguration.java,MultiGpuTracer.java— op routing config and device-switch tracingDeviceType.java— enum: CPU, CUDA, ROCM, TPU, HEXAGON, OPENCL, METAL, VULKANFramework Diagnostics Facade (30+ files in
org/nd4j/linalg/framework/)Framework.java— lazy-initialized subsystem tree entry pointexec/:ExecutionSubsystem.java,DspPlanIntrospection.java,DspStats.java,ExecutionStats.java,KernelStats.java— DSP plan and execution monitoringdevice/:DeviceSubsystem.java,TransferSubsystem.java,TransferEvent.java,TransferReport.java,TransferStats.java,PointerStabilityGuard.java,ReplicaLeakDetector.java— device transfer tracking and pointer stabilitymemory/:MemorySubsystem.java,MemoryEnvironment.java,MemoryState.java— memory usage snapshotshistory/:ArrayLifecycleTracker.java,MemorySampler.java,WorkspaceSampler.java— lifecycle and memory samplingleak/:LeakDetector.java,LeakReport.java,PotentialLeak.java— memory leak detectionprofiling/,constant/,workspace/,stats/:ProfilingSubsystem.java,ConstantCacheSubsystem.java,WorkspaceSubsystem.java,FrameworkSnapshot.java,DiagnosticIssue.java— profiling, constant cache, workspace, and health snapshot subsystemsMemory Infrastructure (9 files)
HybridDataBuffer.java— DataBuffer mirroring host/device with trackedCoherenceStateCoherenceState.java—HOST_ONLY,DEVICE_ONLY,SYNCHRONIZEDenumMemoryCoherenceManager.java— manages coherence state across DataBuffersMultiBackendWorkspace.java,MultiBackendWorkspaceManager.java— workspace abstractions spanning multiple backendsabstracts/DefaultMultiBackendWorkspace.java,NativeMultiBackendWorkspace.java— default and native workspace implementationsdeallocation/OpaqueDataBufferDeallocator.java,OpaqueNDArrayDeallocator.java— separate deallocators for opaque native handlesconf/DeviceAwareWorkspaceConfiguration.java— per-device workspace configurationGraph Tracing Primitives (7 files)
GraphFunction.java—@FunctionalInterface INDArray[] apply(INDArray[] inputs)GraphScope.java— tracesGraphFunctioncalls into a hidden SameDiff graphCompiledGraphFunction.java— cached, compiled graph ready for repeated DSP executionLazyINDArray.java— proxy during tracing:shape()/dataType()work, data access throwsIllegalStateException; trackssdVariableNamefor graph wiringDeviceAwareNDArrayFactory.java,DeviceAwareNd4j.java,MultiBackendContext.java— device-routed array factory and backend contextFactory and Backend Registration (8 files)
BackendManager.java,BackendRegistry.java— centralized backend lifecycle and registry replacing ad-hocServiceLoadercallsfactory/config/:CoreEnvironmentConfig.java,CudaEnvironmentConfig.java,DspEnvironmentConfig.java,LifecycleEnvironmentConfig.java,MemoryConfig.java,TritonEnvironmentConfig.java— typed@Builderconfigs replacing scatteredSystem.getProperty()callsTritonSectionType.java— Triton kernel section type enumAdam8bit Optimizer (3 files)
config/Adam8bit.java— 8-bit Adam: INT8 per-block absmax quantization,DEFAULT_BLOCK_SIZE=2048, ~4x optimizer state reductionAdam8bitUpdater.java— dequantize → Adam update → requantize per blockBlockQuantizationUtils.java— block-wise INT8 absmax quantization utilitiesDataset Curation Toolkit (20 files in
org/nd4j/linalg/dataset/curation/)MinHasher.java,TextDeduplicator.java— MinHash LSH deduplication (Jaccard similarity viahashA/hashBarrays,LARGE_PRIME=4294967311L)NGramDecontaminator.java— N-gram decontamination removing test-set leakageLengthBucketingIterator.java,PaddingFreeBatchCollator.java— bucket-sorted batching to minimize padding wasteCurriculumIterator.java,DifficultyScorer.java— curriculum learning with pluggable difficulty scoringSequencePacker.java,PackedSequence.java— bin-packing sequences into context windowsWeightedDataMixer.java— weighted domain mixing for pretraining blendsTextQualityFilter.java,ChatTemplate.java,InstructionDataFormatter.java,StratifiedSplitter.java,AudioDataProcessor.java— quality filtering, chat template formatting, stratified splits, audio preprocessingRawTextDatasetIterator.java,TokenizedTextDataIterator.java— raw and tokenized text iteratorsOp Namespace Extensions (updated)
NDMath,NDBase,NDBitwise,NDCNN,NDImage,NDLinalg,NDLoss,NDNN,NDRNN,NDRandom— synchronized with new ops from PR13NDAudio.java— audio op namespace (Mel spectrogram, MFCC, pitch detection, Griffin-Lim)NDSignal.java— signal processing (DFT, STFT, windowing functions)NDTraining.java— training ops (gradient accumulation, loss scaling)Common Infrastructure (8 files)
common/config/properties/DspProperties.java,TritonProperties.java— typed property accessorsND4JSystemProperties.java,ND4JEnvironmentVars.java— extended with ~30 new DSP/Triton/multi-device propertiesschedule/CosineWarmupSchedule.java— cosine annealing + linear warmup LR schedulenativeblas/MultiBackendNativeOpsHolder.java,NativePluginLoader.java— plugin-based native ops loadingtools/TritonCacheTool.java— CLI for inspecting/invalidating Triton plan disk cachend4j-common-tests:TestResultStore,TestResultQuery,TestMilestonefor persistent test milestone trackingSerialization / ONNX Export (2 files)
OnnxTensorUtils.java—INDArray↔ ONNX tensor conversionOnnxExporter.java,OnnxExportConfig.java— SameDiff → ONNX export including INT8/FP16 quantized exportDependencies
DeviceContextProvider/DeviceDescriptor), PR15 (training uses new config classes), PR16 (DSP runtime usesGraphScope,DspEnvironmentConfig,DspPlanDiskCache)Merge Order
These 22 PRs must merge in layer order. Each layer depends on the layers above it being merged first. PRs within the same layer are independent and can merge in parallel.