-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDA_rc.py
executable file
·288 lines (211 loc) · 7.51 KB
/
DA_rc.py
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
#!/usr/bin/env python3
#
# Authors: Christoph Lehner 2020 / Philipp Scior 2021
#
# Calculate pion DA with A2A method
#
import gpt as g
import os
#import numpy as np
from gpt_qpdf_utils import pion_DA_measurement
# configure
#root_output = "/p/project/chbi21/gpt_test/DA"
root_output ="."
# 420, 500, 580
groups = {
"booster_batch_0": {
"confs": [
"420",
"1960",
"2000",
],
#"evec_fmt": "/p/scratch/gm2dwf/evecs/96I/%s/lanczos.output",
"evec_fmt": "/p/project/chbi21/gpt_test/96I/lanczos.output",
"conf_fmt": "/p/project/chbi21/gpt_test/96I/ckpoint_lat.%s",
},
}
parameters = {
"zmax" : 24,
"pzmin" : 0,
"pzmax" : 5,
"width" : 2.2,
"pos_boost" : [0,0,0],
"neg_boost" : [0,0,0],
"save_propagators" : True
}
jobs = {
"booster_exact_0": {
"exact": 1,
"sloppy": 0,
"low": 0,
},
"booster_sloppy_0": {
"exact": 0,
"sloppy": 10,
"low": 0,
},
}
jobs_per_run = g.default.get_int("--gpt_jobs", 1)
# find jobs for this run
def get_job(only_on_conf=None):
# statistics
n = 0
for group in groups:
for job in jobs:
for conf in groups[group]["confs"]:
n += 1
jid = -1
# for job in jobs:
# for group in groups:
# for conf in groups[group]["confs"]:
for group in groups:
for conf in groups[group]["confs"]:
for job in jobs:
jid += 1
if only_on_conf is not None and only_on_conf != conf:
continue
root_job = f"{root_output}/{conf}/{job}"
if not os.path.exists(root_job):
os.makedirs(root_job)
return group, job, conf, jid, n
return None
if g.rank() == 0:
first_job = get_job()
run_jobs = str(
list(
filter(
lambda x: x is not None,
[first_job] + [get_job(first_job[2]) for i in range(1, jobs_per_run)],
)
)
).encode("utf-8")
else:
run_jobs = bytes()
run_jobs = eval(g.broadcast(0, run_jobs).decode("utf-8"))
# every node now knows what to do
# configuration needs to be the same for all jobs, so load eigenvectors and configuration
conf = run_jobs[0][2]
group = run_jobs[0][0]
##### small dummy used for testing
grid = g.grid([8,8,8,8], g.double)
rng = g.random("seed text")
U = g.qcd.gauge.random(grid, rng)
# loading gauge configuration
#U = g.load(groups[group]["conf_fmt"] % conf)
g.message("finished loading gauge config")
# do gauge fixing
U_prime, trafo = g.gauge_fix(U, maxiter=500)
del U_prime
L = U[0].grid.fdimensions
Measurement = pion_DA_measurement(parameters)
#prop_exact, prop_sloppy, pin = Measurement.make_96I_inverter(U, groups[group]["evec_fmt"])
prop_exact, prop_sloppy = Measurement.make_debugging_inverter(U)
phases = Measurement.make_mom_phases(U[0].grid)
# show available memory
g.mem_report(details=False)
g.message(
"""
================================================================================
DA run on booster ; this run will attempt:
================================================================================
"""
)
# per job
for group, job, conf, jid, n in run_jobs:
g.message(
f"""
Job {jid} / {n} : configuration {conf}, job tag {job}
"""
)
job_seed = job.split("_correlated")[0]
rng = g.random(f"DA-ensemble-{conf}-{job_seed}")
source_positions_sloppy = [
[rng.uniform_int(min=0, max=L[i] - 1) for i in range(4)]
for j in range(jobs[job]["sloppy"])
]
source_positions_exact = [
[rng.uniform_int(min=0, max=L[i] - 1) for i in range(4)]
for j in range(jobs[job]["exact"])
]
g.message(f" positions_sloppy = {source_positions_sloppy}")
g.message(f" positions_exact = {source_positions_exact}")
root_job = f"{root_output}/{conf}/{job}"
Measurement.set_output_facilites(f"{root_job}/correlators",f"{root_job}/propagators")
g.message("Starting Wilson loops")
W = Measurement.create_WL(U)
# exact positions
for pos in source_positions_exact:
g.message("STARTING EXACT MEASUREMENTS")
g.message("Starting DA 2pt function")
g.message("Generatring boosted src's")
srcDp, srcDm = Measurement.create_src_2pt(pos, trafo, U[0].grid)
g.message("Starting prop exact")
prop_exact_f = g.eval(prop_exact * srcDp)
g.message("forward prop done")
prop_exact_b = g.eval(prop_exact * srcDm)
g.message("backward prop done")
tag = "%s/%s" % ("exact", str(pos))
prop_b = Measurement.constr_backw_prop_for_DA(prop_exact_b,W)
g.message("Start DA contractions")
Measurement.contract_DA(prop_exact_f, prop_b, phases, tag)
del prop_b
g.message("DA done")
g.message("Starting 2pt contraction (includes sink smearing)")
Measurement.contract_2pt(prop_exact_f, prop_exact_b, phases, trafo, tag)
g.message("2pt contraction done")
if(parameters["save_propagators"]):
Measurement.propagator_output(tag, prop_exact_f, prop_exact_b)
del prop_exact_f
del prop_exact_b
g.message("STARTING SLOPPY MEASUREMENTS")
g.message("Starting DA 2pt function")
g.message("Starting prop sloppy")
prop_sloppy_f = g.eval(prop_sloppy * srcDp)
g.message("forward prop done")
prop_sloppy_b = g.eval(prop_sloppy * srcDm)
g.message("backward prop done")
del srcDp
del srcDm
tag = "%s/%s" % ("sloppy", str(pos))
prop_b = Measurement.constr_backw_prop_for_DA(prop_sloppy_b,W)
g.message("Start DA contractions")
Measurement.contract_DA(prop_sloppy_f, prop_b, phases, tag)
del prop_b
g.message("DA done")
g.message("Starting 2pt contraction (includes sink smearing)")
Measurement.contract_2pt(prop_sloppy_f, prop_sloppy_b, phases, trafo, tag)
g.message("2pt contraction done")
if(parameters["save_propagators"]):
Measurement.propagator_output(tag, prop_sloppy_f, prop_sloppy_b)
del prop_sloppy_f
del prop_sloppy_b
g.message("exact positions done")
# sloppy positions
for pos in source_positions_sloppy:
g.message("STARTING SLOPPY MEASUREMENTS")
tag = "%s/%s" % ("sloppy", str(pos))
g.message("Starting DA 2pt function")
g.message("Generatring boosted src's")
srcDp, srcDm = Measurement.create_src_2pt(pos, trafo, U[0].grid)
g.message("Starting prop exact")
prop_sloppy_f = g.eval(prop_sloppy * srcDp)
g.message("forward prop done")
prop_sloppy_b = g.eval(prop_sloppy * srcDm)
g.message("backward prop done")
del srcDp
del srcDm
prop_b = Measurement.constr_backw_prop_for_DA(prop_sloppy_b,W)
g.message("Start DA contractions")
Measurement.contract_DA(prop_sloppy_f, prop_b, phases, tag)
g.message("DA contractions done")
del prop_b
g.message("Starting pion 2pt function")
g.message("Starting pion contraction (includes sink smearing)")
Measurement.contract_2pt(prop_sloppy_f, prop_sloppy_b, phases, trafo, tag)
g.message("pion contraction done")
if(parameters["save_propagators"]):
Measurement.propagator_output(tag, prop_sloppy_f, prop_sloppy_b)
del prop_sloppy_f
del prop_sloppy_b
g.message("sloppy positions done")
#del pin