Repository navigation
feat(analytic): add a stacked 3D DRAM memory model and memory-aware latency estimate - #121
Merged
Merged
Conversation
…atency estimate PerfModel charges HBM prefetch/store instructions one cycle, so llama_model.py assumes the memory system always keeps up. analytic_models/stacked_dram adds the missing memory term and a 3D-stacked DRAM model to price it: - StackedDramConfig/DramTimingConfig: peak bandwidth from the connected layers, vertical-connectivity efficiency (a given endpoint or bank row timing), capacity, and DRAM-wave quantisation of transfers. - BufferingPolicy (Little's-law bandwidth cap), ThermalPolicy (compute-clock derating with stack height) and DramEnergyConfig (pJ/bit). - FixedBandwidthMemory for baselines; JSON profiles with strict keys and SHA-256 provenance. - estimate_decoder_latency: PerfModel compute exactly as in llama_model.py plus per-stage DRAM traffic (weights, KV cache, activation spills), combined by a stage-roofline or serial overlap. Reports TTFT/TPS, memory-bound time, DRAM bytes and energy, and the footprint against capacity. - python -m analytic_models.stacked_dram describe|estimate, and the just recipes stacked-dram-describe, stacked-dram-estimate and test-stacked-dram. The memory mechanisms are ported from DeepStack (arXiv:2604.04750, tile-ai/DeepStack@8509061) and each module names its source. PLENA does not depend on DeepStack, and no hardware values ship with the package: every parameter comes from the caller and the example profiles are fictional. Verified: 75 unit tests pass; with unbounded bandwidth the estimate matches llama_model.py's TTFT/TPS to 1e-12; the ported equations match DeepStack on 153 reference values to 2e-16 (checked outside the repository); ruff clean.
GeorgeWu1204
approved these changes
Oct 25, 2026
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
Adds
analytic_models/stacked_dram: a 3D-stacked DRAM memory model and a memory-aware TTFT/TPS estimate for one PLENA chip.PerfModelchargesH_PREFETCH_*a single cycle, so the TTFT and TPS ofllama_model.pyassume the memory system always keeps up. This adds the missing memory term. A memory is either a fixed-bandwidth baseline (for example a datasheet HBM number) or a DRAM stack whose usable bandwidth follows from its height, vertical connectivity, buffering and thermal limits, so the same decoder can be compared across stack designs.The memory mechanisms are ported from DeepStack (Mo et al., MICRO 2026, arXiv:2604.04750), and every module names the DeepStack source it follows (tile-ai/DeepStack@8509061). The package has no runtime or test dependency on DeepStack. No hardware values ship with it: a design is a JSON profile, and the two example profiles are deliberately fictional.
Mechanisms
src/deepstack/mosaic/arch/custom_profile.pysrc/deepstack/mosaic/dse_space/case_study_dram_layer/dram_layer_config.pysrc/tilesight/tilesight/fused_op_dtype_wave/matmul_fused_op_new_api_wave.pysrc/deepstack/mosaic/arch/custom_profile.py,src/deepstack/mosaic/cost/energy.pyGPU-only fields (L2 multiplier, uncached utilisation, the bank-oracle clock) are dropped, the memory clock moves into the DRAM configuration, and DeepStack's per-SM quantities become per-requester (DMA stream) quantities.
Estimate
Each stage, meaning the embedding lookup and every transformer block, takes
max(cycles / f, bytes / usable bandwidth)(stage-roofline, the default, which is how DeepStack prices an operator) or their sum (serial). The compute term isllama_model.py'sPerfModelcalls, including its ×2 decode issue factor. Traffic per block:H_PREFETCH_Mloop offlash_attention);PerfModelspills them past Vector SRAM (both RMSNorms, the projection, the residual);[ANALYTIC.PRECISION]inplena_settings.toml(MXFP8 by default).The result reports TTFT, TPS, per-phase compute and memory time with the memory-bound share, DRAM bytes and energy, weights + KV against capacity, and warnings (buffering cap, thermal derating,
head_dim × heads ≠ hidden_size). MoE decoders are rejected here; the multi-chip follow-up handles them.Validation
llama_model.py's TTFT and TPS (relative error ≤ 1e-12).ruff format --check .andruff check .pass with the locked ruff.Also in this PR
093de4eamakesanalytic_modelsimportable and installable:main'sanalytic_models/__init__.pyimportsmemoryandutilisation, which do not exist, andpyproject.tomldoes not includeanalytic_models*. #103 and #118 carry the same fix. Whichever lands first, the others resolve the conflict by keeping the union of imports.Follow-ups
MemoryProvideradapter, so that the compiler-trace latency model of Add compiler-derived compute and HBM latency models #103 can price HBM traffic with a stack profile.