File size: 8,673 Bytes
55e1701
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2f194a8
55e1701
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Megatron Memory Estimator</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <div class="container">
        <h1>Megatron Memory Estimator</h1>
        <div class="disclaimer-banner">
    Note: This estimator only measures the GPU memory directly managed by PyTorch when running Megatron. It does not include extra consumption from NCCL communication buffers, kernel fusion, overlap optimizations, CUDA Graphs, etc. Please use the "Overhead per GPU" option below to account for these additional costs.
</div>
        
        <div class="main-layout">
            <div class="top-section">
                <div class="config-column">
                    <form id="config-form">
                <h2>Configuration</h2>
                        <div class="form-group">
                            <label for="model-select">Select a Local Config:</label>
                            <select id="model-select" name="model">
                                <option value="">Loading...</option>
                            </select>
                        </div>

                        <!-- All settings are now in one block -->
                        <div class="form-row">
                            <div class="form-group">
                                <label for="num-gpus">Total GPUs:</label>
                                <input type="number" id="num-gpus" name="num_gpus" value="8" step="8" min="8">
                            </div>
                    <div class="form-group">
                                <label for="mbs">micro batch size:</label>
                                <input type="number" id="mbs" name="mbs" value="1" min="1">
                    </div>
                    <div class="form-group">
                                <label for="seq-len">SeqLen:</label>
                                <input type="number"id="seq-len" name="seq-len" value="4096" min="1">
                            </div>
                        </div>
                        
                        <div class="form-group">
                            <input type="checkbox" id="use-distributed-optimizer" name="use_distributed_optimizer" checked>
                            <label for="use-distributed-optimizer" class="inline-label">Use Distributed Optimizer</label>
                        </div>

                        <div class="form-row">
                            <div class="form-group">
                                <label for="recompute-granularity">Recomputation:</label>
                                <select id="recompute-granularity" name="recompute_granularity">
                                    <option value="none">None</option>
                                    <option value="selective">Selective</option>
                                    <option value="full">Full</option>
                                </select>
                            </div>
                            <div class="form-group recompute-options" style="display: none;">
                                <label for="recompute-method">Method:</label>
                                <select id="recompute-method" name="recompute_method">
                                    <option value="uniform">Uniform</option>
                                    <option value="block">Block</option>
                                </select>
                            </div>
                            <div class="form-group recompute-options" style="display: none;">
                                <label for="recompute-num-layers">Layers:</label>
                                <input type="number" id="recompute-num-layers" name="recompute_num_layers" value="1" min="1">
                            </div>
                        </div>

                        <div class="form-row">
                            <div class="form-group">
                                <label for="tp">TP:</label>
                                <select id="tp" name="tp"></select>
                    </div>
                    <div class="form-group">
                                <label for="pp">PP:</label>
                        <input type="number" id="pp" name="pp" value="1" min="1">
                    </div>
                    <div class="form-group">
                                <label for="ep">EP:</label>
                                <select id="ep" name="ep"></select>
                            </div>
                            <div class="form-group">
                                <label for="cp">CP:</label>
                                <select id="cp" name="cp"></select>
                            </div>
                        </div>
                        <div class="form-row">
                            <div class="form-group">
                                <label for="vpp">VPP:</label>
                                <input type="number" id="vpp" name="vpp" placeholder="None" min="1">
                    </div>
                    <div class="form-group">
                                <label for="etp">ETP:</label>
                                <input type="number" id="etp" name="etp" placeholder="None" min="1">
                            </div>
                        </div>
                        <div class="form-row">
                            <div class="form-group">
                                <label for="num_layers_in_first_pipeline_stage">First Stage Layers:</label>
                                <input type="number" id="num_layers_in_first_pipeline_stage" name="num_layers_in_first_pipeline_stage" placeholder="None" min="0">
                    </div>
                    <div class="form-group">
                                <label for="num_layers_in_last_pipeline_stage">Last Stage Layers:</label>
                                <input type="number" id="num_layers_in_last_pipeline_stage" name="num_layers_in_last_pipeline_stage" placeholder="None" min="0">
                            </div>
                        </div>
                        <div class="form-row">
                            <div class="form-group">
                                <label for="overhead">Overhead per GPU:</label>
                                <select id="overhead" name="overhead">
                                    <option value="5">5GB</option>
                                    <option value="10" selected>10GB</option>
                                </select>
                            </div>
                        </div>

                        <div id="validation-message" class="error-message" style="display: none;"></div>
                        <div class="button-container">
                            <button type="submit">Estimate</button>
                    </div>
                </form>
                </div>

                <div class="output-column">
                    <div class="config-editor-wrapper">
                        <h2>Model Config (Editable)</h2>
                        <textarea id="config-editor" rows="20"></textarea>
                    </div>
                </div>
            </div>

            <div class="bottom-section">
                <div id="output-container">
                    <div id="loading" style="display: none;">Calculating...</div>
                    <div id="history-wrapper">
                        <h3>History</h3>
                        <table id="history-table">
                            <thead>
                                <tr>
                                    <th>Model</th>
                                    <th>Weight Optimizer (GB)</th>
                                    <th>Activation (GB)</th>
                                    <th>Total (GB/GPU)</th>
                                    <th>Actions</th>
                                </tr>
                            </thead>
                            <tbody>
                            </tbody>
                        </table>
                        <button id="clear-history" style="margin-top: 1em;">Clear History</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script src="script.js"></script>
    <footer class="footer">
        <p>&copy; 2025 <a href="https://github.com/ISEEKYAN" target="_blank">ISEEKYAN</a>. Developed at NVIDIA. | <a href="https://github.com/ISEEKYAN/mbridge/tree/main/memory_estimator" target="_blank">Source Code</a></p>
    </footer>
</body>
</html>