Skip to content

1.0.0 rewrite#1100

Open
agibsonccc wants to merge 9 commits into
masterfrom
1.0.0-rewrite
Open

1.0.0 rewrite#1100
agibsonccc wants to merge 9 commits into
masterfrom
1.0.0-rewrite

Conversation

@agibsonccc

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

This contains the examples for the rewrite release.

How was this patch tested?

Please review
https://github.com/eclipse/deeplearning4j/blob/master/CONTRIBUTING.md before opening a pull request.

This is a bridge release branch before complete Java package renamespacing.
Maven groupId is fully migrated to org.eclipse.deeplearning4j; Java source
packages (org.deeplearning4j, org.nd4j, org.datavec) remain unchanged for now.

Changes across all modules:
- Java 11 minimum (was Java 8), using maven-compiler-plugin release=11
- Snapshot repo moved to https://central.sonatype.com/repository/maven-snapshots/
- CUDA backend updated to nd4j-cuda-12.9-platform (was 10.2)
- All module versions normalized to 1.0.0-SNAPSHOT
- API fixes: int[] -> long[] for ArgMax, ListBuilder import path
- New examples: SameDiff LLM/VLM/audio, OmniHub, GGML, attention, capsule net,
  advanced training (LoRA, distillation, mixed precision), and more
- Updated README.md and CLAUDE.md documenting bridge release status
…namespace issues

- Expand root README with detailed per-module example listings and NEW tags
- Rewrite samediff-examples README covering LLM, VLM, audio, ops, training, DSP sections
- Add onnx-import-examples README covering ONNX import and OmniHub examples
- Expand dl4j-examples README with new CNN, evaluation, and architecture examples
- Fix android-examples groupIds to org.eclipse.deeplearning4j and version to 1.0.0-SNAPSHOT
- Update android-examples snapshot repository URL
- Modernize CI workflow: Java 11, ubuntu-latest, actions v4, skip android/oreilly modules
Reorganization:
- dl4j-examples: rename modelling -> modeling (American English)
- dl4j-examples: rename charmodelling -> charmodeling
- dl4j-examples: move evaluation/initialization/listeners/normalization/
  optimization/serialization from quickstart/modeling/ to quickstart/features/
- samediff-examples: split modeling/ into llm/, vlm/, audio/ subdirectories

New examples:
- python4j-examples module: Python4jBasicsExample, NumpyBridgeExample
- Pipeline: AutoModelExample, TokenizerExample
- Ops: TransformerOpsAdvancedExample (FlashAttention, GQA, RoPE),
  MoEAndSSMOpsExample (MoE, Mamba-2 SSM)
- Training: FP8TrainingExample, Adam8bitGradientAccumulationExample
- Generation: SpeculativeDecodingExample, ContinuousBatchingExample
- Evaluation: LLMEvalBenchmarkExample

Update READMEs, CI workflow excludes python4j-examples (requires Python runtime)
Replace 5 examples that were walls of System.out.println with
code-as-strings. Each now constructs real objects, runs real
computations, and prints actual results:

- AutoModelExample: builds SameDiff model, saves to .sdz, loads
  via AutoModel.fromPretrained(), verifies round-trip, inspects
  LoadConfig and ModelFormat
- TokenizerExample: creates minimal BPE tokenizer from JSON,
  exercises encode/decode/vocab/batch/chat template APIs
- SpeculativeDecodingExample: builds NgramSpeculators with various
  configs, feeds token context, computes acceptance rate/speedup
- ContinuousBatchingExample: constructs scheduler and prefill
  engine, computes static vs continuous batching throughput
- LLMGenerationPipelineExample: creates all SamplingConfig presets,
  builds GenerationPipelineConfig, demonstrates sampling math
Verified every import, constructor, and method call against the actual
JAR class signatures. All 54 source files now compile cleanly.

- TokenizerExample: idToToken→getToken, tokenToId→getTokenId
- AutoModelExample: fix LoadConfig builder fields, use ModelFormat.fromFilename
- ContinuousBatchingExample: fix package imports, constructor-based API
- LLMGenerationPipelineExample: fix builder fields (maxKvCacheLength, etc)
- SpeculativeDecodingExample: use correct NgramSpeculator/SpeculativeDecodeLoop API
- MoEAndSSMOpsExample: fix mamba2Ssm, mixtureOfExperts, moeGate signatures
- TransformerOpsAdvancedExample: fix rope, groupedQueryAttention, kvCacheUpdate
- Adam8bitGradientAccumulationExample: fix getLearningRate(epoch, iter)
- FP8TrainingExample: use mixedPrecision() instead of nonexistent fp8Training()
- LLMEvalBenchmarkExample: fix EvalResult/EvalRunner/benchmark constructor APIs
- pom.xml: add samediff-pipeline-core dependency
… integration

New examples (6,500+ lines):
- GraphOptimizerQuantizedTrainingExample: 11 quantized training scenarios
  (PTQ, QAT, mixed precision, FP8, Adam8bit, INT8, block quantization,
  gradient accumulation, checkpointing, layer-sensitive, full pipeline)
- LoRAFineTuningExample: end-to-end LoRA with DSP training section
- QLoRAAndAdvancedAdaptersExample: 13+ PEFT methods with DSP section
- SFTTrainingPipelineExample: full SFT pipeline with DSP section
- RLAlignmentTrainingExample: DPO/GRPO/PPO/KTO/ORPO with DSP section
- DistillationTrainingPipelineExample: multi-mode distillation with DSP
- ContinuedPretrainingExample: domain adaptation with DSP section

Each example builds real models, runs actual training, and prints numeric output.
DSP sections demonstrate DspHandle phase tracking and warmup vs steady-state.
Fixed Python-style SLF4J format specifiers ({:.6f} → String.format) across all files.
Per-language, self-contained examples of the SDX serving SDK (the sdx* C ABI
in dsp_runtime_c.h), each walking the same lifecycle: input-contract
discovery (constants + weights + placeholders, discovered by name), warmup,
freezeShapes -> DSP replay, execution-report telemetry, canonical output
verification, and the error path.

Each example ships an idiomatic wrapper following its ecosystem's ML-runtime
conventions:

- java-end-to-end:    ORT-Java-style SdxEnvironment/SdxSession/SdxTensor
                      client package (JNA hidden); also hosts
                      GenerateExampleModel, which produces the shared
                      models/mlp.sdz fixture + canonical vector
- python-end-to-end:  numpy-first run_named(feed_dict), get_inputs()
                      metadata, frozen ExecutionSummary dataclass
- rust-end-to-end:    ndarray-based run_named_shaped via the wrapper crate's
                      ndarray feature, typed error enum
- csharp-end-to-end:  DenseTensor<float> named-input Run, record DTO,
                      nullable-enabled, pin-for-call-duration interop
- kotlin-end-to-end:  runNamed(map), FloatTensor, typed PlanPhase/SdxBackend
                      enums, use{} chains
- swift-end-to-end:   value-type SdxTensor, [String: SdxTensor] run,
                      CustomStringConvertible report
- typescript/node:    ORT-node-style classes over koffi, Float32Array
                      tensors, Symbol.dispose/using
- typescript/react-native: TurboModule spec + SdxSession class + useSdxModel
                      hook over an Android JNI/C++ and iOS ObjC++ bridge
- typescript/wasm:    ORT-web-style wrapper over an Emscripten MODULARIZE
                      module at explicit wasm32 struct offsets; marshaling
                      proven against a pure-JS reference ABI that computes
                      the MLP from the marshaled heap bytes; build-wasm.sh
                      Emscripten recipe + browser demo

Verified on Linux CPU: java, python, rust, and typescript/node run green
against the canonical vector; react-native and wasm TS surfaces typecheck;
csharp/kotlin/swift are inspection-verified (no local toolchains).
… fix example run failures

New examples:
- GpuDeviceFailoverExample: DeviceMemoryManager routing, memory caps, pressure
  callbacks, and OOM failover (GPU -> other GPU -> CPU) via simulation mode
- GenerationSessionContinuationExample: resumable decode via GenerationSession
  (ADR 0105), verifies greedy generate(N)+continue(M) == generate(N+M)
- AbliterationExample: training-free residual-stream editing (Arditi et al.),
  RefusalDirectionFinder + WeightOrthogonalizer + AbliterationWorkflow, synthetic
  and self-verifying (recovered direction ~= planted, weights orthogonalized)

Example fixes (verified end-to-end):
- GGMLImportExport: skip null-array input placeholders when counting parameters
- AutoModel: write .sdz with SDZSerializer.save (zip) instead of SameDiff.save
  (which writes the FlatBuffers .sdnb format)
- SmolDoclingVLM: feed the vision encoder its real inputs (pixel_values +
  pixel_attention_mask) via the VisionEncoder helper; Idefics3 prompt format;
  now generates real DocTags
- TokenizerExample: valid byte-level BPE tokenizer.json (paired merges, Gtoken)
- GraphOptimizerQuantizedTraining: keep loss reachable through optimize(); move
  FP16 weight cast to a post-training deployment stage
- RLAlignmentTraining: declare logits2D for the 2D-logit toy policies
- Nd4jEx2: replace removed rand(seed, long[]) overload with setSeed + rand
- Ops examples (deconv2d/spaceToBatch, dft/embedding, lstm/gru/sru, mixture-of-
  experts / selective-scan, rmsNorm output name, eig via svd cross-check):
  correct op input shapes/layouts and output names

READMEs updated for the new examples.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant